1

I am developing a C# ORM with php's Laravel-like Syntax. When the ORM starts, it connects to the database and performs any query (it also supports two different connections for reading and writing), and reconnect to the db only if connection is losen or missing.

As this is a Web Framework ORM, how can I handle concurrent transactions on the same connection? Are they supported?

I saw I can manually assign the transaction object to the sqlcommand, but can I create parallel sqltransactions?

Example:

There is an URL of a REST action that will cause a transaction to be opened, some actions performed, and then transaction committed (e.g. perform an order on a shopping cart). What if, multiple users (so different WebOperationContext) call that URL? Is it possible to open and work with multiple "parallel" transactions and then commit them?

How do other ORM's handle this case? Did they use multiple connections?

Thanks for any support!

Mattia

1 Answer 1

3

SQL Server does not support parallel transactions on the same connection.

Normally, there is no need for that. Just open connections as you need them. This is cheap thanks to pooling.

A common model is to open connection and transaction right after another. Then, commit and dispose everything at the end.

That way concurrent HTTP requests do not interact at all which is good.

Sign up to request clarification or add additional context in comments.

2 Comments

So this is SQL Server specific right? Other DB engines or ODBC drivers may allow parallel transactions in the same connection, right?
Yes, they might. The DB engine and the driver must support this. Is this relevant for you? The question is tagged SQL Server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.