Ejemplo n.º 1
0
        public void AssociateTransaction_SqlCommand_CommandTransactionIsSameAsExpected()
        {
            var definitionProvider = new DataAnnotationsDefinitionProvider();
            var statementCompiler  = new TransactSqlAdapter(definitionProvider);

            using (var connection = new SqlConnection(ConfigurationRoot.GetConnectionString("MasterDatabase")))
                using (var database = new DatabaseContext(connection, statementCompiler))
                {
                    database.OpenSharedConnection();
                    var command = new SqlCommand("SELECT * FROM sys.tables WHERE [type] = @0");

                    using (var transaction = database.BeginTransaction(IsolationLevel.RepeatableRead))
                    {
                        database.AssociateTransaction(command);
                        Assert.IsNotNull(command.Transaction);
                    }
                }
        }