Beispiel #1
0
        public static System.Data.IsolationLevel ToDataIsolationLevel(this IsolationLevel level)
        {
            System.Data.IsolationLevel systemLevel = System.Data.IsolationLevel.Serializable;
            switch (level)
            {
            case IsolationLevel.Chaos:
                systemLevel = System.Data.IsolationLevel.Chaos;
                break;

            case IsolationLevel.Serializable:
                systemLevel = System.Data.IsolationLevel.Serializable;
                break;

            case IsolationLevel.ReadCommitted:
                systemLevel = System.Data.IsolationLevel.ReadCommitted;
                break;

            case IsolationLevel.ReadUncommitted:
                systemLevel = System.Data.IsolationLevel.ReadUncommitted;
                break;

            case IsolationLevel.RepeatableRead:
                systemLevel = System.Data.IsolationLevel.RepeatableRead;
                break;

            case IsolationLevel.Snapshot:
                systemLevel = System.Data.IsolationLevel.Snapshot;
                break;

            case IsolationLevel.Unspecified:
                systemLevel = System.Data.IsolationLevel.Snapshot;
                break;
            }
            return(systemLevel);
        }
        public static IsolationLevel Map(System.Transactions.IsolationLevel isolationLevel)
        {
            switch (isolationLevel)
            {
            case System.Transactions.IsolationLevel.Serializable:
                return(IsolationLevel.Serializable);

            case System.Transactions.IsolationLevel.RepeatableRead:
                return(IsolationLevel.RepeatableRead);

            case System.Transactions.IsolationLevel.ReadCommitted:
                return(IsolationLevel.ReadCommitted);

            case System.Transactions.IsolationLevel.ReadUncommitted:
                return(IsolationLevel.ReadUncommitted);

            case System.Transactions.IsolationLevel.Snapshot:
                return(IsolationLevel.Snapshot);

            case System.Transactions.IsolationLevel.Chaos:
                return(IsolationLevel.Chaos);

            case System.Transactions.IsolationLevel.Unspecified:
                return(IsolationLevel.Unspecified);
            }

            return(IsolationLevel.ReadCommitted);
        }
Beispiel #3
0
        public static string ConvertToSqlString(System.Transactions.IsolationLevel iso)
        {
            string isoLevel = "read committed";

            switch (iso)
            {
            case System.Transactions.IsolationLevel.Chaos:
            case System.Transactions.IsolationLevel.ReadUncommitted:
                isoLevel = "READ UNCOMMITTED";
                break;

            case System.Transactions.IsolationLevel.RepeatableRead:
                isoLevel = "REPEATABLE READ";
                break;

            case System.Transactions.IsolationLevel.Serializable:
                isoLevel = "SERIALIZABLE";
                break;

            case System.Transactions.IsolationLevel.Snapshot:
                isoLevel = "SNAPSHOT";
                break;
            }
            return(isoLevel);
        }
Beispiel #4
0
        /// <summary>
        /// Converts <see cref="System.Transactions.IsolationLevel"/> to <see cref="IsolationLevel"/>.
        /// </summary>
        public static IsolationLevel ToSystemDataIsolationLevel(this System.Transactions.IsolationLevel isolationLevel)
        {
            switch (isolationLevel)
            {
            case System.Transactions.IsolationLevel.Chaos:
                return(IsolationLevel.Chaos);

            case System.Transactions.IsolationLevel.ReadCommitted:
                return(IsolationLevel.ReadCommitted);

            case System.Transactions.IsolationLevel.ReadUncommitted:
                return(IsolationLevel.ReadUncommitted);

            case System.Transactions.IsolationLevel.RepeatableRead:
                return(IsolationLevel.RepeatableRead);

            case System.Transactions.IsolationLevel.Serializable:
                return(IsolationLevel.Serializable);

            case System.Transactions.IsolationLevel.Snapshot:
                return(IsolationLevel.Snapshot);

            case System.Transactions.IsolationLevel.Unspecified:
                return(IsolationLevel.Unspecified);

            default:
                throw new CodeZeroException("Unknown isolation level: " + isolationLevel);
            }
        }
Beispiel #5
0
        public static System.Data.IsolationLevel ConvertTodataIsoLevel(System.Transactions.IsolationLevel iso)
        {
            switch (iso)
            {
            case System.Transactions.IsolationLevel.Chaos:
                return(System.Data.IsolationLevel.Chaos);

            case System.Transactions.IsolationLevel.ReadCommitted:
                return(System.Data.IsolationLevel.ReadCommitted);

            case System.Transactions.IsolationLevel.ReadUncommitted:
                return(System.Data.IsolationLevel.ReadUncommitted);

            case System.Transactions.IsolationLevel.RepeatableRead:
                return(System.Data.IsolationLevel.RepeatableRead);

            case System.Transactions.IsolationLevel.Serializable:
                return(System.Data.IsolationLevel.Serializable);

            case System.Transactions.IsolationLevel.Snapshot:
                return(System.Data.IsolationLevel.Snapshot);

            case System.Transactions.IsolationLevel.Unspecified:
                return(System.Data.IsolationLevel.Unspecified);
            }
            return(System.Data.IsolationLevel.Unspecified);
        }
Beispiel #6
0
        public static System.Data.IsolationLevel GetDataIsolationLevel(this System.Transactions.IsolationLevel isolationLevel)
        {
            switch (isolationLevel)
            {
            case System.Transactions.IsolationLevel.Serializable:
                return(System.Data.IsolationLevel.Serializable);

            case System.Transactions.IsolationLevel.RepeatableRead:
                return(System.Data.IsolationLevel.RepeatableRead);

            case System.Transactions.IsolationLevel.ReadCommitted:
                return(System.Data.IsolationLevel.ReadCommitted);

            case System.Transactions.IsolationLevel.ReadUncommitted:
                return(System.Data.IsolationLevel.ReadUncommitted);

            case System.Transactions.IsolationLevel.Snapshot:
                return(System.Data.IsolationLevel.Snapshot);

            case System.Transactions.IsolationLevel.Chaos:
                return(System.Data.IsolationLevel.Chaos);

            case System.Transactions.IsolationLevel.Unspecified:
                return(System.Data.IsolationLevel.Unspecified);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #7
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        private QueryInfo(SerializationInfo info, StreamingContext context)
        {
            _id = info.GetInt32("Id");
            var methodText = info.GetString("Method");

            Method                   = (QueryMethod)Enum.Parse(typeof(QueryMethod), methodText);
            _projection              = (Projection)info.GetValue("Projection", typeof(Projection));
            _entities                = (EntityInfo[])info.GetValue("Entities", typeof(EntityInfo[]));
            _executePredicate        = (QueryExecutePredicate)info.GetValue("ExecutePredicate", typeof(QueryExecutePredicate));
            _groupby                 = (GroupBy)info.GetValue("GroupBy", typeof(GroupBy));
            _having                  = (ConditionalContainer)info.GetValue("Having", typeof(ConditionalContainer));
            _sort                    = (Sort)info.GetValue("Sort", typeof(Sort));
            _whereClause             = (ConditionalContainer)info.GetValue("WhereClause", typeof(ConditionalContainer));
            _takeParameters          = (TakeParameters)info.GetValue("TakeParameters", typeof(TakeParameters));
            _parameters              = (QueryParameterCollection)info.GetValue("Parameters", typeof(QueryParameterCollection));
            _nestedQueries           = (QueryInfo[])info.GetValue("NestedQueries", typeof(QueryInfo[]));
            _unions                  = (UnionInfoCollection)info.GetValue("Unions", typeof(UnionInfoCollection));
            _storedProcedureName     = (StoredProcedureName)info.GetValue("StoredProcedureName", typeof(StoredProcedureName));
            _storedProcedureProvider = info.GetString("StoredProcedureProvider");
            _ignoreRegisterUserInfo  = info.GetBoolean("IgnoreRegisterUserInfo");
            _isolationLevel          = (System.Transactions.IsolationLevel)info.GetInt16("IsolationLevel");
            _commandTimeout          = info.GetInt32("CommandTimeout");
            _providerName            = info.GetString("ProviderName");
            _ignoreTypeSchema        = info.GetBoolean("IgnoreTypeSchema");
        }
        public FbTransaction BeginTransaction(System.Transactions.IsolationLevel isolationLevel)
        {
            switch (isolationLevel)
            {
            case System.Transactions.IsolationLevel.Chaos:
                return(BeginTransaction(System.Data.IsolationLevel.Chaos, null));

            case System.Transactions.IsolationLevel.ReadUncommitted:
                return(BeginTransaction(System.Data.IsolationLevel.ReadUncommitted, null));

            case System.Transactions.IsolationLevel.RepeatableRead:
                return(BeginTransaction(System.Data.IsolationLevel.RepeatableRead, null));

            case System.Transactions.IsolationLevel.Serializable:
                return(BeginTransaction(System.Data.IsolationLevel.Serializable, null));

            case System.Transactions.IsolationLevel.Snapshot:
                return(BeginTransaction(System.Data.IsolationLevel.Snapshot, null));

            case System.Transactions.IsolationLevel.Unspecified:
                return(BeginTransaction(System.Data.IsolationLevel.Unspecified, null));

            case System.Transactions.IsolationLevel.ReadCommitted:
            default:
                return(BeginTransaction(System.Data.IsolationLevel.ReadCommitted, null));
            }
        }
Beispiel #9
0
 public DbTransactionScope(System.Transactions.IsolationLevel isolationLevel, int timeoutInSeconds = 30)
 {
     _transaction = new System.Transactions.CommittableTransaction(
         new System.Transactions.TransactionOptions()
     {
         IsolationLevel = isolationLevel,
         Timeout        = new TimeSpan(0, 0, timeoutInSeconds)
     });
 }
 public void BeginTran(System.Transactions.IsolationLevel isLvl = System.Transactions.IsolationLevel.ReadCommitted)
 {
     EnsureCreated();
     if ((_context.Connection.State & ConnectionState.Open) != ConnectionState.Open)
     {
         _context.Connection.Open();
     }
     _tran = _context.Connection.BeginTransaction(DbHelper.ConvertTodataIsoLevel(isLvl));
     _context.Transaction = _tran;
 }
        /// <summary>
        /// Creates a new transaction scope associated with the specified connection,
        /// using the specified transaction configuration options.
        /// The scope can be nested inside another scope in which case the underlying
        /// db transaction is only committed once both the outer and inner transaction(s)
        /// have been committed. The returned ITransactionScope implements IDisposable
        /// and should be wrapped in a using statement.
        /// </summary>
        /// <param name="dbConnection">
        /// <para>
        /// The DbConnection instance to manage transactions for. Transaction scopes
        /// created by this instance only apply to a single DbConnection, so if you want
        /// the scope to span additional data access mechanism then they must share the
        /// same connection.
        /// </para>
        /// <para>
        /// You can use the ICofoundryDbConnectionManager to get a reference to the shared
        /// connection directly.
        /// </para>
        /// </param>
        /// <param name="transactionScopeOption">This is defaulted to TransactionScopeOption.Required.</param>
        /// <param name="isolationLevel">This is defaulted to IsolationLevel.ReadCommitted.</param>
        /// <returns>ITransactionScope, which is IDisposable and must be disposed.</returns>
        public static ITransactionScope CreateScope(
            this IDomainRepositoryTransactionManager domainRepositoryTransactionManager,
            System.Transactions.TransactionScopeOption transactionScopeOption = System.Transactions.TransactionScopeOption.Required,
            System.Transactions.IsolationLevel isolationLevel = System.Transactions.IsolationLevel.ReadCommitted
            )
        {
            var extendable = domainRepositoryTransactionManager.AsExtendableDomainRepositoryTransactionManager();
            var defaultTransactionScopeManager = CastDefaultTransactionScopeManager(extendable.TransactionScopeManager);

            return(defaultTransactionScopeManager.Create(extendable.DbContext, transactionScopeOption, isolationLevel));
        }
Beispiel #12
0
 public IDbTransactionScope BeginNested(System.Transactions.IsolationLevel isolationLevel)
 {
     ThrowIfHandled();
     // Validate isolationLevel
     if (isolationLevel != System.Transactions.IsolationLevel.Unspecified && isolationLevel != _transaction.IsolationLevel)
     {
         throw new DbTransactionScopeException(
                   $"Cannot start nested {nameof(DbTransactionScope)} because the parent was created with a different IsolationLevel ({_transaction.IsolationLevel.ToString()}) than the provided ({isolationLevel.ToString()}) which is not supported.");
     }
     return(BeginNested());
 }
Beispiel #13
0
        /// <summary>
        /// Creates a new transaction scope associated with the specified connection,
        /// using the specified transaction configuration options.
        /// The scope can be nested inside another scope in which case the underlying
        /// db transaction is only committed once both the outer and inner transaction(s)
        /// have been committed. The returned ITransactionScope implements IDisposable
        /// and should be wrapped in a using statement.
        /// </summary>
        /// <param name="dbConnection">
        /// <para>
        /// The DbConnection instance to manage transactions for. Transaction scopes
        /// created by this instance only apply to a single DbConnection, so if you want
        /// the scope to span additional data access mechanism then they must share the
        /// same connection.
        /// </para>
        /// <para>
        /// You can use the ICofoundryDbConnectionManager to get a reference to the shared
        /// connection directly.
        /// </para>
        /// </param>
        /// <param name="transactionScopeOption">This is defaulted to TransactionScopeOption.Required.</param>
        /// <param name="isolationLevel">This is defaulted to IsolationLevel.ReadCommitted.</param>
        /// <returns>ITransactionScope, which is IDisposable and must be disposed.</returns>
        public static ITransactionScope Create(
            this ITransactionScopeManager transactionScopeManager,
            DbConnection dbConnection,
            System.Transactions.TransactionScopeOption transactionScopeOption = System.Transactions.TransactionScopeOption.Required,
            System.Transactions.IsolationLevel isolationLevel = System.Transactions.IsolationLevel.ReadCommitted
            )
        {
            var defaultTransactionScopeManager = CastDefaultTransactionScopeManager(transactionScopeManager);

            return(defaultTransactionScopeManager.Create(dbConnection, transactionScopeOption, isolationLevel));
        }
Beispiel #14
0
 /// <inheritdoc />
 public IDbTransactionScope BeginTransactionScope(System.Transactions.IsolationLevel isolationLevel, int timeoutInSeconds = 30)
 {
     if (CurrentTransactionScope == null || CurrentTransactionScope.Completed)
     {
         return(CurrentTransactionScope = new DbTransactionScope(this, isolationLevel, timeoutInSeconds));
     }
     else
     {
         return(CurrentTransactionScope.BeginNested(isolationLevel));
     }
 }
 /// <summary>
 /// Converts <see cref="System.Transactions.IsolationLevel"/> to <see cref="IsolationLevel"/>.
 /// </summary>
 public static IsolationLevel ToSystemDataIsolationLevel(this System.Transactions.IsolationLevel isolationLevel)
 {
     return(isolationLevel switch
     {
         System.Transactions.IsolationLevel.Chaos => IsolationLevel.Chaos,
         System.Transactions.IsolationLevel.ReadCommitted => IsolationLevel.ReadCommitted,
         System.Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,
         System.Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,
         System.Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,
         System.Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,
         System.Transactions.IsolationLevel.Unspecified => IsolationLevel.Unspecified,
         _ => throw new Exception("Unknown isolation level: " + isolationLevel),
     });
 internal Transaction(System.Transactions.IsolationLevel isoLevel, InternalTransaction internalTransaction)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     if (internalTransaction != null)
     {
         this.internalTransaction = internalTransaction;
         this.cloneId = Interlocked.Increment(ref this.internalTransaction.cloneCount);
     }
 }
 internal Transaction(System.Transactions.IsolationLevel isoLevel, InternalTransaction internalTransaction)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     if (internalTransaction != null)
     {
         this.internalTransaction = internalTransaction;
         this.cloneId             = Interlocked.Increment(ref this.internalTransaction.cloneCount);
     }
 }
Beispiel #18
0
        public Task <FbTransaction> BeginTransaction(System.Transactions.IsolationLevel isolationLevel, AsyncWrappingCommonArgs async)
        {
            var il = isolationLevel switch
            {
                System.Transactions.IsolationLevel.Chaos => IsolationLevel.Chaos,
                System.Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,
                System.Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,
                System.Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,
                System.Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,
                System.Transactions.IsolationLevel.Unspecified => IsolationLevel.Unspecified,
                _ => IsolationLevel.ReadCommitted,
            };

            return(BeginTransaction(il, null, async));
        }
Beispiel #19
0
        public Task <FbTransaction> BeginTransactionAsync(System.Transactions.IsolationLevel isolationLevel, CancellationToken cancellationToken = default)
        {
            var il = isolationLevel switch
            {
                System.Transactions.IsolationLevel.Chaos => IsolationLevel.Chaos,
                System.Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,
                System.Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,
                System.Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,
                System.Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,
                System.Transactions.IsolationLevel.Unspecified => IsolationLevel.Unspecified,
                _ => IsolationLevel.ReadCommitted,
            };

            return(BeginTransactionAsync(il, null, cancellationToken));
        }
Beispiel #20
0
        public FbTransaction BeginTransaction(System.Transactions.IsolationLevel isolationLevel)
        {
            var il = isolationLevel switch
            {
                System.Transactions.IsolationLevel.Chaos => IsolationLevel.Chaos,
                System.Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,
                System.Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,
                System.Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,
                System.Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,
                System.Transactions.IsolationLevel.Unspecified => IsolationLevel.Unspecified,
                _ => IsolationLevel.ReadCommitted,
            };

            return(BeginTransaction(il, null));
        }
 internal Transaction(System.Transactions.IsolationLevel isoLevel, ISimpleTransactionSuperior superior)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     if (superior == null)
     {
         throw new ArgumentNullException("superior");
     }
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     this.internalTransaction = new InternalTransaction(this, superior);
     this.cloneId             = 1;
 }
 internal Transaction(System.Transactions.IsolationLevel isoLevel, ISimpleTransactionSuperior superior)
 {
     TransactionManager.ValidateIsolationLevel(isoLevel);
     if (superior == null)
     {
         throw new ArgumentNullException("superior");
     }
     this.isoLevel = isoLevel;
     if (System.Transactions.IsolationLevel.Unspecified == this.isoLevel)
     {
         this.isoLevel = TransactionManager.DefaultIsolationLevel;
     }
     this.internalTransaction = new InternalTransaction(this, superior);
     this.cloneId = 1;
 }
Beispiel #23
0
        private static void InvokeDB(Action action, System.Transactions.IsolationLevel isolationLevel)
        {
            var transactionOptions = new System.Transactions.TransactionOptions();

            transactionOptions.IsolationLevel = isolationLevel;
            using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions))
            {
                try
                {
                    action();
                }
                finally
                {
                    transactionScope.Complete();
                }
            }
        }
 public virtual void BeginTran(System.Transactions.IsolationLevel isLvl = System.Transactions.IsolationLevel.ReadCommitted)
 {
 }
        internal OletxTransactionManager(
            string nodeName
            )
        {
            lock ( ClassSyncObject )
            {
                // If we have not already initialized the shim factory and started the notification
                // thread, do so now.
                if (null == OletxTransactionManager.proxyShimFactory )
                {
                    Int32 error = NativeMethods.GetNotificationFactory(
                        OletxTransactionManager.ShimWaitHandle.SafeWaitHandle,
                        out OletxTransactionManager.proxyShimFactory
                        );

                    if ( 0 != error )
                    {
                        throw TransactionException.Create( SR.GetString( SR.TraceSourceOletx ), SR.GetString( SR.UnableToGetNotificationShimFactory ), null );
                    }

                        ThreadPool.UnsafeRegisterWaitForSingleObject(
                            OletxTransactionManager.ShimWaitHandle,
                            new WaitOrTimerCallback( OletxTransactionManager.ShimNotificationCallback ),
                            null,
                            -1,
                            false
                            );
                }
            }
            
            this.dtcTransactionManagerLock = new ReaderWriterLock();

            this.nodeNameField = nodeName;

            // The DTC proxy doesn't like an empty string for node name on 64-bit platforms when
            // running as WOW64.  It treats any non-null node name as a "remote" node and turns off
            // the WOW64 bit, causing problems when reading the registry.  So if we got on empty
            // string for the node name, just treat it as null.
            if (( null != this.nodeNameField ) && ( 0 == this.nodeNameField.Length ))
            {
                this.nodeNameField = null;
            }

            if ( DiagnosticTrace.Verbose )
            {
                DistributedTransactionManagerCreatedTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                    this.GetType(),
                    this.nodeNameField
                    );
            }

            // Initialize the properties from config.
            configuredTransactionOptions.IsolationLevel = isolationLevelProperty = TransactionManager.DefaultIsolationLevel;
            configuredTransactionOptions.Timeout = timeoutProperty = TransactionManager.DefaultTimeout;

            this.internalResourceManager = new OletxInternalResourceManager( this );

            dtcTransactionManagerLock.AcquireWriterLock( -1 );
            try
            {
                this.dtcTransactionManager = new DtcTransactionManager( this.nodeNameField, this );
            }
            finally
            {
                dtcTransactionManagerLock.ReleaseWriterLock();
            }
            
            if (resourceManagerHashTable == null)
            {
                resourceManagerHashTable = new Hashtable(2);
                resourceManagerHashTableLock = new System.Threading.ReaderWriterLock();
            }

        }
Beispiel #26
0
 public DbTransactionScope(DbConnectionScope dbConnectionScope, System.Transactions.IsolationLevel isolationLevel, int timeoutInSeconds = 30)
     : this(isolationLevel, timeoutInSeconds)
 {
     AddConnectionScopeEnlistment(dbConnectionScope, false);
 }
Beispiel #27
0
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            var attribute = reader.GetAttribute("Id");

            int.TryParse(attribute, out _id);
            attribute = reader.GetAttribute("Method");
            if (!string.IsNullOrEmpty(attribute))
            {
                Enum.TryParse <QueryMethod>(attribute, out _method);
            }
            attribute = reader.GetAttribute("IsSelectDistinct");
            bool.TryParse(attribute, out _isSelectDistinct);
            attribute = reader.GetAttribute("IgnoreRegisterUserInfo");
            bool.TryParse(attribute, out _ignoreRegisterUserInfo);
            attribute = reader.GetAttribute("IsolationLevel");
            if (!Enum.TryParse <System.Transactions.IsolationLevel>(attribute, out _isolationLevel))
            {
                _isolationLevel = System.Transactions.IsolationLevel.Unspecified;
            }
            attribute = reader.GetAttribute("CommandTimeout");
            if (!int.TryParse(attribute, out _commandTimeout))
            {
                _commandTimeout = 30;
            }
            _providerName            = reader.GetAttribute("ProviderName");
            _storedProcedureProvider = reader.GetAttribute("StoredProcedureProvider");
            attribute = reader.GetAttribute("IgnoreTypeSchema");
            bool.TryParse(attribute, out _ignoreTypeSchema);
            reader.ReadStartElement();
            _projection       = ReadItem <Projection>(reader, "Projection");
            _executePredicate = ReadItem <QueryExecutePredicate>(reader, "ExecutePredicate");
            var entitiesQueue = new Queue <EntityInfo>();

            if (!reader.IsEmptyElement && reader.LocalName == "Entities")
            {
                reader.ReadStartElement("Entities", Namespaces.Query);
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    var join = new EntityInfo();
                    ((System.Xml.Serialization.IXmlSerializable)join).ReadXml(reader);
                    entitiesQueue.Enqueue(join);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _entities = entitiesQueue.ToArray();
            var joinsQueue = new Queue <JoinInfo>();

            if (!reader.IsEmptyElement && reader.LocalName == "Joins")
            {
                reader.ReadStartElement("Joins", Namespaces.Query);
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    var join = new JoinInfo();
                    ((System.Xml.Serialization.IXmlSerializable)join).ReadXml(reader);
                    joinsQueue.Enqueue(join);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _joins          = joinsQueue.ToArray();
            _whereClause    = ReadItem <ConditionalContainer>(reader, "Where");
            _sort           = ReadItem <Sort>(reader, "Sort");
            _groupby        = ReadItem <GroupBy>(reader, "GroupBy");
            _having         = ReadItem <ConditionalContainer>(reader, "Having");
            _takeParameters = ReadItem <TakeParameters>(reader, "TakeParameters");
            var nestedQueries = new List <QueryInfo>();

            if (!reader.IsEmptyElement && reader.LocalName == "NestedQueries")
            {
                reader.ReadStartElement("NestedQueries", Namespaces.Query);
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    var queryInfo = new QueryInfo();
                    ((System.Xml.Serialization.IXmlSerializable)queryInfo).ReadXml(reader);
                    nestedQueries.Add(queryInfo);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _nestedQueries = nestedQueries.ToArray();
            _parameters    = new QueryParameterCollection();
            if (!reader.IsEmptyElement && reader.LocalName == "Parameters")
            {
                reader.ReadStartElement("Parameters", Namespaces.Query);
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    var parameter = new QueryParameter();
                    ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                    _parameters.Add(parameter);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _storedProcedureName = ReadItem <StoredProcedureName>(reader, "StoredProcedureName");
            _unions = new UnionInfoCollection();
            if (!reader.IsEmptyElement && reader.LocalName == "Unions")
            {
                reader.ReadStartElement("Unions", Namespaces.Query);
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    var union = new UnionInfo();
                    ((System.Xml.Serialization.IXmlSerializable)union).ReadXml(reader);
                    _unions.Add(union);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            reader.ReadEndElement();
        }
Beispiel #28
0
 /// <summary>
 /// Podesavanje isolation levela za sve konekcije globalno.
 /// Svaka konekcija moze overrajdati svoj isolation level.
 /// </summary>
 /// <param name="isolation"></param>
 public static void SetIsolationLevel(System.Transactions.IsolationLevel isolation)
 {
     transactionIsolation = isolation;
 }
Beispiel #29
0
        /// <summary>
        /// Desserializa o objeto.
        /// </summary>
        /// <param name="reader"></param>
        void ICompactSerializable.Deserialize(Colosoft.Serialization.IO.CompactReader reader)
        {
            _id = reader.ReadInt32();
            _isSelectDistinct       = reader.ReadBoolean();
            _ignoreRegisterUserInfo = reader.ReadBoolean();
            try
            {
                Enum.TryParse <QueryMethod>(reader.ReadString(), out _method);
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            _isolationLevel   = (System.Transactions.IsolationLevel)reader.ReadInt16();
            _commandTimeout   = reader.ReadInt32();
            _providerName     = reader.ReadString();
            _ignoreTypeSchema = reader.ReadBoolean();
            if (reader.ReadBoolean())
            {
                _storedProcedureProvider = reader.ReadString();
            }
            if (reader.ReadBoolean())
            {
                _projection = new Projection();
                ((ICompactSerializable)_projection).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                _executePredicate = new QueryExecutePredicate();
                ((ICompactSerializable)_executePredicate).Deserialize(reader);
            }
            var entitiesQueue = new Queue <EntityInfo>();

            while (reader.ReadBoolean())
            {
                var entity = new EntityInfo();
                ((ICompactSerializable)entity).Deserialize(reader);
                entitiesQueue.Enqueue(entity);
            }
            _entities = entitiesQueue.ToArray();
            var joinQueue = new Queue <JoinInfo>();

            while (reader.ReadBoolean())
            {
                var join = new JoinInfo();
                ((ICompactSerializable)join).Deserialize(reader);
                joinQueue.Enqueue(join);
            }
            _joins = joinQueue.ToArray();
            if (reader.ReadBoolean())
            {
                _whereClause = new ConditionalContainer();
                ((ICompactSerializable)_whereClause).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                _sort = new Sort();
                ((ICompactSerializable)_sort).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                _groupby = new GroupBy();
                ((ICompactSerializable)_groupby).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                _having = new ConditionalContainer();
                ((ICompactSerializable)_having).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                _takeParameters = new TakeParameters();
                ((ICompactSerializable)_takeParameters).Deserialize(reader);
            }
            var nestedQueries = new List <QueryInfo>();

            while (reader.ReadBoolean())
            {
                var nestedQuery = new QueryInfo();
                ((ICompactSerializable)nestedQuery).Deserialize(reader);
                nestedQueries.Add(nestedQuery);
            }
            _nestedQueries = nestedQueries.ToArray();
            if (_parameters == null)
            {
                _parameters = new QueryParameterCollection();
            }
            while (reader.ReadBoolean())
            {
                var parameter = new QueryParameter();
                parameter.Deserialize(reader);
                _parameters.Add(parameter);
            }
            if (reader.ReadBoolean())
            {
                _storedProcedureName = new StoredProcedureName();
                ((ICompactSerializable)_storedProcedureName).Deserialize(reader);
            }
            if (_unions == null)
            {
                _unions = new UnionInfoCollection();
            }
            while (reader.ReadBoolean())
            {
                var union = new UnionInfo();
                union.Deserialize(reader);
                _unions.Add(union);
            }
        }
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="providerName"></param>
 /// <param name="isolationLevel"></param>
 public QueryExecutionGroup(string providerName, System.Transactions.IsolationLevel isolationLevel)
 {
     ProviderName   = providerName;
     IsolationLevel = isolationLevel;
 }
 public override void BeginTran(
     System.Transactions.IsolationLevel isLvl = System.Transactions.IsolationLevel.ReadCommitted)
 {
     BeginCount = BeginCount + 1;
 }
 public void BeginTran(System.Transactions.IsolationLevel isLvl = System.Transactions.IsolationLevel.ReadCommitted)
 {
     EnsureCreated();
     _tran = _context.BeginTransaction(DbHelper.ConvertTodataIsoLevel(isLvl));
 }
 internal Transaction(OletxTransaction oleTransaction)
 {
     this.isoLevel = oleTransaction.IsolationLevel;
     this.internalTransaction = new InternalTransaction(this, oleTransaction);
     this.cloneId = Interlocked.Increment(ref this.internalTransaction.cloneCount);
 }
 public SubordinateTransaction(System.Transactions.IsolationLevel isoLevel, System.Transactions.ISimpleTransactionSuperior superior)
 {
 }
 internal Transaction(OletxTransaction oleTransaction)
 {
     this.isoLevel            = oleTransaction.IsolationLevel;
     this.internalTransaction = new InternalTransaction(this, oleTransaction);
     this.cloneId             = Interlocked.Increment(ref this.internalTransaction.cloneCount);
 }