Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use Isolation level in LINQ

Posted on 2009-05-05
2
Medium Priority
?
3,514 Views
Last Modified: 2013-11-11
I try to use isolation level with L2E, but I've this problem:

The transaction specified for TransactionScope has a different IsolationLevel than the value requested for the scope. Parameter name: transactionOptions.IsolationLevel

And I dont understand why.

This error is displayed when I call my dedicated method:
public static int insertDB(InsertDbDelegate methodThatWriteDB, IsolationLevel isoLevel, MasterPage senderPage)
    {
        int objectsAdded = 0;
 
        try
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = isoLevel }))
            {
                using (geststockEntities gse = new geststockEntities(cs_admin))
                {
                    methodThatWriteDB(gse);
                    objectsAdded = gse.SaveChanges();
                    if (objectsAdded == 0) throw new Exception();
                    scope.Complete();
                    gse.Connection.Close();
                    addUserMessage(senderPage, "Insertion OK");
                }
            }
        }
        catch (Exception ex)
        {
            addErrorMessage(senderPage, "Error when connecting to the database." + ex.Message);
        }
 
        return objectsAdded;
    }

Open in new window

0
Comment
Question by:Nargzul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Expert Comment

by:Eugene Z
ID: 24325574
please post an error that you got

also check if it is related to your problem:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=325381&wa=wsignin1.0
0
 
LVL 1

Accepted Solution

by:
Nargzul earned 0 total points
ID: 24326032
Interception de System.Data.EntityException
  Message="Échec du fournisseur sous-jacent sur Open."
  Source="System.Data.Entity"
  StackTrace:
       à System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
       à System.Data.EntityClient.EntityConnection.Open()
       à System.Data.Objects.ObjectContext.EnsureConnection()
       à System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
       à System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
       à System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
       à System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__0[TResult](IEnumerable`1 sequence)
       à System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
       à System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
       à System.Linq.Queryable.First[TSource](IQueryable`1 source)
       à pages_Default.makeLoan(geststockEntities gse) dans d:\WorkSpaces\geststock\GestStock2\pages\makeLoan.aspx.cs:ligne 169
       à QueryHelper.insertDB(InsertDbDelegate methodThatWriteDB, IsolationLevel isoLevel, MasterPage senderPage) dans d:\WorkSpaces\geststock\GestStock2\App_Code\QueryHelper.cs:ligne 157
  InnerException: System.Transactions.TransactionManagerCommunicationException
       Message="L'accès réseau de MSDTC (Distributed Transaction Manager) a été désactivé. Activez DTC pour l'accès réseau dans la configuration de sécurité de MSDTC à l'aide de l'outil administratif des services de composants."
       Source="System.Transactions"
       StackTrace:
            à System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)
            à System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken)
            à System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction tx)
            à System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction tx)
            à System.Transactions.EnlistableStates.Promote(InternalTransaction tx)
            à System.Transactions.Transaction.Promote()
            à System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction)
            à System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
            à System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)
            à System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
            à System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
            à System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)
            à System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
            à System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
            à System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
            à System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
            à System.Data.SqlClient.SqlConnection.Open()
            à System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
       InnerException: System.Runtime.InteropServices.COMException
            Message="Le gestionnaire de transactions a désactivé sa prise en charge de transactions à distance/réseau. (Exception de HRESULT : 0x8004D024)"
            Source="System.Transactions"
            ErrorCode=-2147168220
            StackTrace:
                 à System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim)
                 à System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken)
            InnerException:
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question