Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Transactions source warnings when using Linq-2-Sql

I've enabled System.Transactions logging:

<system.diagnostics>
    <sources>
        <source name="System.Transactions" switchValue="Warning">
            -- my listeners here
        </source>
    </sources>
</system.diagnostics>

and see A LOT of strange log warnings like:

  • Transaction.Rollback Called
  • Enlistment Callback Negative
  • TransactionScope Incomplete

Can please somebody shed some light on it? My system works as expected and there are no ADO.NET level exceptions raised. The DAL code is typical L2S code without explicit transaction management or any hacks.

like image 640
UserControl Avatar asked Jan 31 '12 11:01

UserControl


People also ask

How does LINQ to SQL support transactions?

LINQ to SQL supports transactions as a part of its architecture, and there are three types of transactions in LINQ to SQL. When you call SubmitChanges (), LINQ to SQL starts a local transaction by default and uses it to execute the generated SQL commands. When all SQL commands have been completed, LINQ to SQL commits the local transaction.

What is an exception when using LINQ to SQL?

An exception is thrown if a different connection is used. You can call LINQ to SQL APIs in the scope of an active Transaction. LINQ to SQL detects that the call is within the scope of a transaction and does not create a new transaction. LINQ to SQL also avoids closing the connection in this case.

Can I use LINQ to perform explicit transactions against a single DataContext?

If you use LINQ to SQL explicit transactions against a single DataContext: You can use TransactionScope – it’s easiest and won’t escalate to DTC within a single DataContext You can also use explicit DataContext.Transaction to manually manage an ADO.NET transaction

What is LINQ to SQL (DLINQ)?

For most ASP.NET developers, LINQ to SQL (also known as DLINQ) is an electrifying part of Language Integrated Query as this allows querying data in SQL server database by using usual LINQ expressions.


Video Answer


1 Answers

Using a switchValue of Warning will pickup more than just errors. From msdn:

A condition exists that can subsequently result in an error or critical failure (for example, allocation failing or approaching a limit). Normal processing of errors from user code (for example, transaction aborted, timeouts, authentication failed) can also generate a warning.

Maybe this is what you want. If so, cool. Otherwise, you may want to change it to Error.

like image 195
Anderson Avatar answered Oct 06 '22 18:10

Anderson