Tuesday, May 25, 2010

Transactions (LINQ to SQL)

Transactions (LINQ to SQL): "HomeLibraryLearnDownloadsSupportCommunity

Sign in |United States - English |Preferences

MSDN Library
.NET Development
.NET Framework 4
.NET Framework Core Development
Data Access and Modeling
ADO.NET
SQL Server and ADO.NET
LINQ to SQL
Programming Guide (LINQ to SQL)
Background Information (LINQ to SQL)
Transactions (LINQ to SQL)
Separator
MSDN
LINQ to SQL
Transactions (LINQ to SQL)

LINQ to SQL supports three distinct transaction models. The following lists these models in the order of checks performed.
Explicit Local Transaction

When SubmitChanges is called, if the Transaction property is set to a (IDbTransaction) transaction, the SubmitChanges call is executed in the context of the same transaction.

It is your responsibility to commit or rollback the transaction after successful execution of the transaction. The connection corresponding to the transaction must match the connection used for constructing the DataContext. An exception is thrown if a different connection is used.
Explicit Distributable Transaction

You can call LINQ to SQL APIs (including but not limited to SubmitChanges) in the scope of an active Transaction. LINQ to SQL detects that the call is in the scope of a transaction and does not create a new transaction. LINQ to SQL also avoids closing the connection in this case. You can perform query and SubmitChanges executions in the context of such a transaction.
Implicit Transaction

When you call SubmitChanges, LINQ to SQL checks to see whether the call is in the scope of a Transaction or if the Transaction property (IDbTransaction) is set to a user-started local transaction. If it finds neither transaction, LINQ to SQL starts a local transaction (IDbTransaction) and uses it to execute the generated SQL commands. When all SQL commands have been successfully completed, LINQ to SQL commits the local transaction and returns.
See Also
Tasks
How to: Bracket Data Submissions by Using Transactions (LINQ to SQL)
Other Resources
Background Information (LINQ to SQL)
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Feedback
Feedback on the Lightweight view
x
Lightweight builds on ScriptFree (loband) by adding features users have requested: a search box and default code language selection
Did the page load quickly?
Yes No
Do you like the page design?
Yes No
How useful is this topic?
Tell us more
Page view tracker


- Sent using Google Toolbar"

No comments:

Post a Comment