• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Interfaces.esTransactionScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中EntitySpaces.Interfaces.esTransactionScope的典型用法代码示例。如果您正苦于以下问题:C# esTransactionScope类的具体用法?C# esTransactionScope怎么用?C# esTransactionScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



esTransactionScope类属于EntitySpaces.Interfaces命名空间,在下文中一共展示了esTransactionScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PgDataTypeTest

		public void PgDataTypeTest()
		{
            DateTime testTime = Convert.ToDateTime("0001-01-01 01:23:45.678");
            PgDataTypes datatypeTest = new PgDataTypes();

            switch (datatypeTest.es.Connection.ProviderSignature.DataProviderName)
            {
                case "EntitySpaces.Npgsql2Provider":
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        datatypeTest.TimeType = testTime;
                        datatypeTest.Save();

                        long? tempKey = datatypeTest.Id;

                        datatypeTest = new PgDataTypes();
                        Assert.IsTrue(datatypeTest.LoadByPrimaryKey(tempKey.Value));
                        Assert.IsTrue(datatypeTest.TimeType.HasValue);
                        Assert.AreEqual(datatypeTest.TimeType.Value, testTime);
                        datatypeTest.MarkAsDeleted();
                        datatypeTest.Save();
                    }
					break;

				default:
					Assert.Ignore("PostgreSQL only");
					break;
			}
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:29,代码来源:PgFixture.cs


示例2: SetGuidPrimaryKey

		public void SetGuidPrimaryKey()
		{
            GuidTest dataTest = new GuidTest();
            dataTest.es.Connection.Name = "GuidTest";

            switch (dataTest.es.Connection.ProviderMetadataKey)
            {
                case "esSqlCe":
                case "esSqlCe4":
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        string testGuid = "b3883c65-ff94-47c4-8b0c-76896bedd45a";
                        dataTest = new GuidTest();
                        dataTest.es.Connection.Name = "GuidTest";
                        dataTest.GuidKey = new Guid(testGuid);
                        dataTest.Save();
                        Guid? tempKey = dataTest.GuidKey;
                        dataTest.MarkAsDeleted();
                        dataTest.Save();
                        Assert.AreEqual(testGuid, tempKey.Value.ToString());
                    }
                    break;

                default:
                    Assert.Ignore("SqlCe only");
                    break;
            }
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:28,代码来源:SqlCeFixture.cs


示例3: ConcurrencyOnUpdate

        public void ConcurrencyOnUpdate()
        {
            ComputedTestCollection collection = new ComputedTestCollection();
            int testId = 0;

            switch (collection.es.Connection.ProviderSignature.DataProviderName)
            {
                case "EntitySpaces.SybaseSqlAnywhereProvider":
                    try
                    {
                        using (esTransactionScope scope = new esTransactionScope())
                        {
                            // Setup
                            ComputedTest entity = new ComputedTest();
                            entity.Save();
                            testId = entity.Id.Value;

                            // Test
                            entity = new ComputedTest();
                            entity.LoadByPrimaryKey(testId);
                            entity.str().SomeDate = "2007-01-01";

                            ComputedTest entity2 = new ComputedTest();
                            entity2.LoadByPrimaryKey(testId);
                            entity2.str().SomeDate = "1999-12-31";

                            entity.Save();
                            entity2.Save();
                            Assert.Fail("Concurrency Exception not thrown.");
                        }
                    }
                    catch (EntitySpaces.Interfaces.esConcurrencyException cex)
                    {
                        string err = cex.InnerException.Message.Substring(0, 11);
                        Assert.AreEqual("Error", cex.Message.Substring(0, 5));
                        Assert.AreEqual("Concurrency", err);
                    }
                    finally
                    {
                        ComputedTest entity = new ComputedTest();
                        if (entity.LoadByPrimaryKey(testId))
                        {
                            entity.MarkAsDeleted();
                            entity.Save();
                        }
                    }
                    break;

                default:
                    Assert.Ignore("Sybase only.");
                    break;
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:53,代码来源:SybaseFixture.cs


示例4: SaveComposite

        public void SaveComposite()
        {
            using (esTransactionScope scope = new esTransactionScope())
            {
                OrderItemCollection coll = new OrderItemCollection();
                coll.es.Connection.Name = "ForeignKeyTest";

                OrderItem entity = coll.AddNew();
                entity.OrderID = 9;
                entity.ProductID = 1;
                entity.UnitPrice = 1000;
                entity.Quantity = 1000;
                entity = coll.AddNew();
                entity.OrderID = 9;
                entity.ProductID = 2;
                entity.UnitPrice = 1000;
                entity.Quantity = 1000;
                entity = coll.AddNew();
                entity.OrderID = 9;
                entity.ProductID = 3;
                entity.UnitPrice = 1000;
                entity.Quantity = 1000;

                coll.Save();

                coll = new OrderItemCollection();
                coll.es.Connection.Name = "ForeignKeyTest";

                coll.Query.Where(coll.Query.OrderID == 9);
                Assert.IsTrue(coll.Query.Load());
                Assert.AreEqual(3, coll.Count);

                // Clean up
                coll.MarkAllAsDeleted();
                coll.Save();

                coll = new OrderItemCollection();
                coll.es.Connection.Name = "ForeignKeyTest";

                coll.Query.Where(coll.Query.OrderID == 9);
                Assert.IsFalse(coll.Query.Load());

                coll = new OrderItemCollection();
                coll.es.Connection.Name = "ForeignKeyTest";

                Assert.IsTrue(coll.LoadAll());
                Assert.AreEqual(15, coll.Count);
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:49,代码来源:SaveFixture.cs


示例5: MySQLNumericTypeTest

		public void MySQLNumericTypeTest()
		{
			MysqltypetestCollection datatypeTestColl = new MysqltypetestCollection();
			Mysqltypetest datatypeTest = new Mysqltypetest();

			// There is a bug in the 1.0.7 Connector/Net for unsigned types.
			// It is fixed in 5.0.3.
            switch (datatypeTestColl.es.Connection.ProviderSignature.DataProviderName)
            {
                case "EntitySpaces.MySqlClientProvider":
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        datatypeTest.BigIntType = -1;
                        datatypeTest.BigIntUType = 1;
                        datatypeTest.DblType = -1;
                        datatypeTest.DblUType = 1;
                        datatypeTest.DecType = (decimal)(-1.5);
                        datatypeTest.DecUType = (decimal)(1.5);
                        datatypeTest.FloatType = (float)(-1.5);
                        datatypeTest.FloatUType = (float)(1.5);
                        datatypeTest.IntType = -1;
                        datatypeTest.IntUType = 1;
                        datatypeTest.MedIntType = -1;
                        datatypeTest.MedIntUType = 1;
                        datatypeTest.NumType = (decimal)(-1.5);
                        datatypeTest.NumUType = (decimal)(1.5);
                        datatypeTest.RealType = -1.5;
                        datatypeTest.RealUType = 1.5;
                        datatypeTest.SmallIntType = -1;
                        datatypeTest.SmallIntUType = 1;
                        datatypeTest.TinyIntType = (sbyte)(1);
                        datatypeTest.TinyIntUType = Convert.ToByte(1);

                        datatypeTest.Save();

                        int? tempKey = datatypeTest.Id;
                        Assert.IsTrue(datatypeTest.LoadByPrimaryKey(tempKey.Value));
                        datatypeTest.MarkAsDeleted();
                        datatypeTest.Save();
                    }
					break;

				default:
					Assert.Ignore("MySQL only");
					break;
			}
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:47,代码来源:MySQLFixture.cs


示例6: TestSaveWithAutoKey

		public void TestSaveWithAutoKey()
		{
            int terrKey = -1;
            Territory terr = new Territory();
            terr.es.Connection.Name = "ForeignKeyTest";
            TerritoryEx terrEx = new TerritoryEx();
            terrEx.es.Connection.Name = "ForeignKeyTest";

            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    terr.Description = "Some New Territory";

                    terrEx = terr.TerritoryEx;
                    terrEx.Notes = "Test Group";

                    terr.Save();

                    terrKey = terr.TerritoryID.Value;

                    Assert.IsTrue(terr.TerritoryEx.es.HasData);
                    Assert.AreEqual(terr.TerritoryID.Value, terrEx.TerritoryID.Value);

                    terr = new Territory();
                    terr.es.Connection.Name = "ForeignKeyTest";

                    Assert.IsTrue(terr.LoadByPrimaryKey(terrKey));
                    Assert.IsTrue(terr.TerritoryEx.es.HasData);
                }
            }
            finally
            {
                // Clean up
                terr = new Territory();
                terr.es.Connection.Name = "ForeignKeyTest";

                if (terr.LoadByPrimaryKey(terrKey))
                {
                    terrEx = terr.TerritoryEx;
                    terrEx.MarkAsDeleted();
                    terr.MarkAsDeleted();
                    terr.Save();
                }
            }
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:46,代码来源:OneToOneFixture.cs


示例7: TestTransactions

		public void TestTransactions()
		{
			switch (aggTest.es.Connection.Name)
			{
				case "SQLStoredProcEnterprise":
				case "SQLDynamicEnterprise":
				case "ORACLEStoredProcEnterprise":
				case "ORACLEDynamicEnterprise":
				case "VistaDBDynamic":
					Assert.Ignore("Using esTransactionScope only");
					break;

				default:
                    int tempId1 = 0;
                    int tempId2 = 0;

                    aggTest = new AggregateTest();
                    AggregateTest aggTest2 = new AggregateTest();

                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        aggTest.Save();
                        tempId1 = aggTest.Id.Value;
                        aggTest2.Save();
                        tempId2 = aggTest2.Id.Value;

                        scope.Complete();
                    }

                    aggTest = new AggregateTest();
                    Assert.IsTrue(aggTest.LoadByPrimaryKey(tempId1));
                    aggTest.MarkAsDeleted();
                    aggTest.Save();

                    aggTest = new AggregateTest();
                    Assert.IsTrue(aggTest.LoadByPrimaryKey(tempId2));
                    aggTest.MarkAsDeleted();
                    aggTest.Save();

					break;
			}
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:42,代码来源:TransactionFixture.cs


示例8: TestDateTime

		public void TestDateTime()
		{
            int testId = -1;
            AggregateTestCollection aggTestColl = new AggregateTestCollection();
            AggregateTest test = new AggregateTest();

            try
            {
                using (EntitySpaces.Interfaces.esTransactionScope scope =
                    new EntitySpaces.Interfaces.esTransactionScope())
                {
                    aggTestColl.Query.Load();
                    aggTestColl.Filter = aggTestColl.AsQueryable().OrderBy(s => s.Id);
                    test = (AggregateTest)aggTestColl[0];
                    DateTime date = test.HireDate.Value;
                    Assert.AreEqual(Convert.ToDateTime("02/16/2000 05:59:31"), date);

                    test = new AggregateTest();
                    test.HireDate = Convert.ToDateTime("12/31/9999");
                    test.Save();
                    testId = test.Id.Value;

                    test = new AggregateTest();
                    Assert.IsTrue(test.LoadByPrimaryKey(testId));
                    Assert.AreEqual(Convert.ToDateTime("12/31/9999"), test.HireDate.Value);
                    test.MarkAsDeleted();
                    test.Save();
                }
            }
            finally
            {
                // Clean up
                test = new AggregateTest();
                if (test.LoadByPrimaryKey(testId))
                {
                    test.MarkAsDeleted();
                    test.Save();
                }
            }
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:40,代码来源:DataTypeFixture.cs


示例9: DataTypeVarCharMax

        public void DataTypeVarCharMax()
        {
            SqlServerTypeTest dataTest = new SqlServerTypeTest();

            switch (dataTest.es.Connection.ProviderSignature.DataProviderName)
            {
                case "EntitySpaces.SqlClientProvider":
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        dataTest = new SqlServerTypeTest();

                        Assert.AreEqual(0, dataTest.es.ModifiedColumns.Count, "Count1");
                        dataTest.VarCharMaxType = "Test";
                        Assert.AreEqual(1, dataTest.es.ModifiedColumns.Count, "Count2");
                        dataTest.Save();
                        long tempKey = dataTest.Id.Value;

                        dataTest = new SqlServerTypeTest();
                        Assert.IsTrue(dataTest.LoadByPrimaryKey(tempKey));
                        Assert.AreEqual("Test", dataTest.VarCharMaxType);

                        Assert.AreEqual(0, dataTest.es.ModifiedColumns.Count, "Count3");
                        dataTest.VarCharMaxType = dataTest.VarCharMaxType;
                        Assert.AreEqual(0, dataTest.es.ModifiedColumns.Count, "Count4");

                        // Clean up
                        dataTest.MarkAsDeleted();
                        dataTest.Save();
                    }
                    break;

                default:
                    Assert.Ignore("Sql Server only");
                    break;
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:36,代码来源:SqlServerFixture.cs


示例10: CommonInit

        /// <summary>
        /// This is the common constructor logic, tx is "this" from the constructor
        /// </summary>
        /// <param name="tx"></param>
        static protected void CommonInit(esTransactionScope tx)
        {
            Stack<esTransactionScope> stack;

            // See if our stack is already created (there is only one per thread)
            object obj = Thread.GetData(txSlot);
            if (obj == null)
            {
                stack = new Stack<esTransactionScope>();
                Thread.SetData(txSlot, stack);
            }
            else
            {
                stack = (Stack<esTransactionScope>)obj;
            }

            // If this transaction is required we need to set it's root
            if (tx.option == esTransactionScopeOption.Required)
            {
                foreach (esTransactionScope esTrans in stack)
                {
                    // The root can be either a Requires or RequiresNew, and a root always points to
                    // itself, therefore, as long as it's not a Suppress and it's pointing to itself
                    // then we know this the next root up on the stack
                    if (esTrans.option != esTransactionScopeOption.Suppress && esTrans == esTrans.root)
                    {
                        tx.root = esTrans;
                        break;
                    }
                }
            }

            // If we didn't find a root, then we are by definition the root
            if (tx.root == null)
            {
                tx.root = tx;
                tx.transactions = new Dictionary<string, Transaction>();
            }

            stack.Push(tx);
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:45,代码来源:esTransactionScope.cs


示例11: SaveDynamicCollection_InsertsUpdates

        private static DataTable SaveDynamicCollection_InsertsUpdates(esDataRequest request)
        {
            DataTable dataTable = CreateDataTable(request);

            using (esTransactionScope scope = new esTransactionScope())
            {
                using (SADataAdapter da = new SADataAdapter())
                {
                    da.AcceptChangesDuringUpdate = false;
                    da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                    SACommand cmd = null;

                    if (!request.IgnoreComputedColumns)
                    {
                        da.RowUpdated += new SARowUpdatedEventHandler(OnRowUpdated);
                    }

                    foreach (esEntitySavePacket packet in request.CollectionSavePacket)
                    {
                        if (packet.RowState != esDataRowState.Added && packet.RowState != esDataRowState.Modified) continue;

                        DataRow row = dataTable.NewRow();
                        dataTable.Rows.Add(row);

                        switch (packet.RowState)
                        {
                            case esDataRowState.Added:
                                cmd = da.InsertCommand = Shared.BuildDynamicInsertCommand(request, packet.ModifiedColumns);
                                SetModifiedValues(request, packet, row);
                                break;

                            case esDataRowState.Modified:
                                cmd = da.UpdateCommand = Shared.BuildDynamicUpdateCommand(request, packet.ModifiedColumns);
                                SetOriginalValues(request, packet, row, false);
                                SetModifiedValues(request, packet, row);
                                row.AcceptChanges();
                                row.SetModified();
                                break;
                        }

                        request.Properties["esDataRequest"] = request;
                        request.Properties["esEntityData"] = packet;
                        dataTable.ExtendedProperties["props"] = request.Properties;

                        DataRow[] singleRow = new DataRow[1];
                        singleRow[0] = row;

                        try
                        {
                            esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);

                            #region Profiling

                            if (sTraceHandler != null)
                            {
                                using (esTraceArguments esTrace = new esTraceArguments(request, cmd, packet, "SaveCollectionDynamic", System.Environment.StackTrace))
                                {
                                    try
                                    {
                                        da.Update(singleRow);
                                    }
                                    catch (Exception ex)
                                    {
                                        esTrace.Exception = ex.Message;
                                        throw;
                                    }
                                }
                            }
                            else

                            #endregion Profiling

                            {
                                da.Update(singleRow);
                            }

                            if (row.HasErrors)
                            {
                                request.FireOnError(packet, row.RowError);
                            }
                        }
                        finally
                        {
                            esTransactionScope.DeEnlist(cmd);
                            dataTable.Rows.Clear();
                        }
                    }
                }

                scope.Complete();
            }

            return dataTable;
        }
开发者ID:jssgarcia,项目名称:ESLite,代码行数:95,代码来源:DataProvider.cs


示例12: SaveDynamicCollection_Deletes

        static private DataTable SaveDynamicCollection_Deletes(esDataRequest request)
        {
            SACommand cmd = null;

            DataTable dataTable = CreateDataTable(request);

            using (esTransactionScope scope = new esTransactionScope())
            {
                using (SADataAdapter da = new SADataAdapter())
                {
                    da.AcceptChangesDuringUpdate = false;
                    da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                    try
                    {
                        da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                        cmd = da.DeleteCommand = Shared.BuildDynamicDeleteCommand(request, request.CollectionSavePacket[0]);
                        esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);

                        DataRow[] singleRow = new DataRow[1];

                        // Delete each record
                        foreach (esEntitySavePacket packet in request.CollectionSavePacket)
                        {
                            DataRow row = dataTable.NewRow();
                            dataTable.Rows.Add(row);

                            SetOriginalValues(request, packet, row, true);
                            row.AcceptChanges();
                            row.Delete();

                            singleRow[0] = row;
                            da.Update(singleRow);

                            if (row.HasErrors)
                            {
                                request.FireOnError(packet, row.RowError);
                            }

                            dataTable.Rows.Clear(); // ADO.NET won't let us reuse the same DataRow
                        }
                    }
                    finally
                    {
                        esTransactionScope.DeEnlist(cmd);
                    }
                }
                scope.Complete();
            }

            return request.Table;
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:53,代码来源:DataProvider.cs


示例13: NativeMaterializeTest

 protected override void NativeMaterializeTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         var simplests = new SimplestsCollection();
         int i = 0;
         while (i < count)
         {
             simplests.LoadAll();
             foreach (var o in simplests)
                 if (++i >= count)
                     break;
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:16,代码来源:EntitySpacesTest.cs


示例14: NativeQueryTest

 protected override void NativeQueryTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         for (int i = 0; i < count; i++)
         {
             var simplests = new SimplestsCollection();
             var id = i % InstanceCount;
             simplests.Query.Where(simplests.Query.Id == id);
             if (simplests.Query.Load())
                 foreach (var simplest in simplests)
                 {
                     // Doing nothing, just enumerate
                 }
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:18,代码来源:EntitySpacesTest.cs


示例15: ClientSideAliased

        public void ClientSideAliased()
        {
            int keyId = -1;
            CustomClientAliasedCollection coll = new CustomClientAliasedCollection();

            switch (coll.es.Connection.ProviderSignature.DataProviderName)
            {
                case "EntitySpaces.EffiProzProvider":
                    Assert.Ignore("Not implemented");
                    break;

                default:
                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        // Setup
                        CustomClientAliased entity = new CustomClientAliased();

                        entity = new CustomClientAliased();
                        entity.FirstName = "Test";
                        entity.LastName = "One";

                        // Insert
                        entity.Save();
                        keyId = entity.AutoKey.Value;

                        Assert.AreEqual(entity.FirstName, "Test");
                        Assert.AreEqual(entity.LastName, "One");
                        Assert.AreEqual(entity.Age.Value, 40);
                        Assert.AreEqual(entity.DateAddedAlias.Value.Day, DateTime.UtcNow.Day);
                        Assert.AreEqual(entity.DateModified.Value.Day, DateTime.UtcNow.Day);
                        Assert.AreEqual(entity.AddedBy, "AddedBy Client User");
                        Assert.AreEqual(entity.ModifiedByAlias, "ModifiedBy Client User");
                        Assert.AreEqual(entity.EsVersion.Value, 1);

                        // Update
                        entity = new CustomClientAliased();
                        entity.LoadByPrimaryKey(keyId);

                        Assert.AreEqual(entity.FirstName, "Test");
                        Assert.AreEqual(entity.LastName, "One");
                        Assert.AreEqual(entity.Age.Value, 40);
                        Assert.AreEqual(entity.DateAddedAlias.Value.Day, DateTime.UtcNow.Day);
                        Assert.AreEqual(entity.DateModified.Value.Day, DateTime.UtcNow.Day);
                        Assert.AreEqual(entity.AddedBy, "AddedBy Client User");
                        Assert.AreEqual(entity.ModifiedByAlias, "ModifiedBy Client User");
                        Assert.AreEqual(entity.EsVersion.Value, 1);

                        DateTime modified = entity.DateModified.Value;
                        entity.LastName = "Two";
                        System.Threading.Thread.Sleep(4);
                        entity.Save();

                        Assert.AreEqual(entity.FirstName, "Test");
                        Assert.AreEqual(entity.LastName, "Two");
                        Assert.AreEqual(entity.Age.Value, 40);
                        Assert.AreEqual(entity.DateAddedAlias.Value.Day, DateTime.UtcNow.Day);
                        Assert.AreEqual(entity.DateModified.Value.Day, DateTime.UtcNow.Day);
                        Assert.Greater(entity.DateModified.Value, modified);
                        Assert.AreEqual(entity.AddedBy, "AddedBy Client User");
                        Assert.AreEqual(entity.ModifiedByAlias, "ModifiedBy Client User");
                        Assert.AreEqual(entity.EsVersion.Value, 2);

                        // No Update
                        entity = new CustomClientAliased();
                        entity.LoadByPrimaryKey(keyId);
                        DateTime added = entity.DateAddedAlias.Value;
                        modified = entity.DateModified.Value;

                        entity.Save();

                        Assert.AreEqual(entity.FirstName, "Test");
                        Assert.AreEqual(entity.LastName, "Two");
                        Assert.AreEqual(entity.Age.Value, 40);
                        Assert.AreEqual(entity.DateAddedAlias.Value, added);
                        Assert.AreEqual(entity.DateModified.Value, modified);
                        Assert.AreEqual(entity.AddedBy, "AddedBy Client User");
                        Assert.AreEqual(entity.ModifiedByAlias, "ModifiedBy Client User");
                        Assert.AreEqual(entity.EsVersion.Value, 2);

                        // Clean up
                        entity = new CustomClientAliased();
                        entity.LoadByPrimaryKey(keyId);

                        Assert.AreEqual(entity.FirstName, "Test");
                        Assert.AreEqual(entity.LastName, "Two");
                        Assert.AreEqual(entity.Age.Value, 40);
                        Assert.AreEqual(entity.DateAddedAlias.Value, added);
                        Assert.AreEqual(entity.DateModified.Value, modified);
                        Assert.AreEqual(entity.AddedBy, "AddedBy Client User");
                        Assert.AreEqual(entity.ModifiedByAlias, "ModifiedBy Client User");
                        Assert.AreEqual(entity.EsVersion.Value, 2);

                        entity.MarkAsDeleted();
                        entity.Save();

                        entity = new CustomClientAliased();
                        if (entity.LoadByPrimaryKey(keyId))
                        {
                            Assert.Fail("Not deleted");
                        }
//.........这里部分代码省略.........
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:101,代码来源:CustomFieldsFixture.cs


示例16: FetchTest

 protected override void FetchTest(int count)
 {
     long sum = (long) count * (count - 1) / 2;
     using (var ts = new esTransactionScope())
     {
         for (int i = 0; i < count; i++)
         {
             var id = (long) i % InstanceCount;
             var simplest = new Simplests();
             simplest.LoadByPrimaryKey(id);
             sum -= simplest.Id.Value;
         }
         ts.Complete();
     }
     if (count <= InstanceCount)
         Assert.AreEqual(0, sum);
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:17,代码来源:EntitySpacesTest.cs


示例17: CompiledLinqQueryTest

 protected override void CompiledLinqQueryTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         for (int i = 0; i < count; i++)
         {
             var id = i % InstanceCount;
             var query = new SimplestsCollection();
             query.Load(_db, _compiledQuery(_db, id));
             foreach (var simplest in query)
             {
                 // Doing nothing, just enumerate
             }
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:17,代码来源:EntitySpacesTest.cs


示例18: Submit

		/// <summary>
		/// Used to Save the data to the database
		/// </summary>
		/// <returns>True if Successful</returns>
        public override bool Submit(ChangeSet changeSet)
        {
            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    bool success= base.Submit(changeSet);

                    if (success)
                    {
                        scope.Complete();
                    }

                    return success;
                }
            }
            catch (Exception ex)
            {
                if (!HandleError(ex))
                {
                    throw;
                }

                return true;
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:30,代码来源:esDomainService.cs


示例19: LinqMaterializeTest

 protected override void LinqMaterializeTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         var simplests = new SimplestsCollection();
         int i = 0;
         while (i < count)
         {
             simplests.Load(_db, _db.GetTable<Simplests>().Where(o => o.Id > 0));
             foreach (var o in simplests)
                 if (++i >= count)
                     break;
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:16,代码来源:EntitySpacesTest.cs


示例20: RadGrid1_InsertCommand

        protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            DateTime TransDateMonth = DateTime.Now;
            try
            {
                TransDateMonth = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
            int transDateMonth = TransDateMonth.Month;
            //perubahan terakhir, autonumber mengikuti bulan transaksi, bukan bulan berjalan
            //string month = DateTime.Now.Month.ToString().Trim();
            string month = transDateMonth.ToString().Trim();
            string autonumber = "";
            if (month.Length == 1)
                month = ('0' + month).Trim();

            Trans Trans = new Trans();
            //Auto Number
            AutoNumberingQuery anQ = new AutoNumberingQuery();
            anQ.SelectAll();
            anQ.Where(anQ.KaMonth == month, anQ.KaYear == DateTime.Now.Year.ToString().Trim());
            AutoNumberingCollection anColl = new AutoNumberingCollection();

            anColl.Load(anQ);
            //KelAnggaranQuery kaQ = new KelAnggaranQuery();
            //kaQ.SelectAll();
            //kaQ.Where(kaQ.KaCode == (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedValue.Trim());
            //KelAnggaranCollection kaColl = new KelAnggaranCollection();

            //kaColl.Load(kaQ);            

            if (anColl.Count == 0)
            {
                AutoNumberingCollection anCollection = new AutoNumberingCollection();
                AutoNumbering aN = new AutoNumbering();
                aN = anCollection.AddNew();
                aN.KaYear = DateTime.Now.Year.ToString().Trim();
                aN.KaMonth = month;
                aN.LastNumber = 1;
                aN.PrefixNumber = "000";
                //AutoNumbering an = new AutoNumbering { KaYear = DateTime.Now.Year.ToString().Trim(), KaMonth = month, LastNumber = 1, PrefixNumber = "000" };
                autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month);
                //an.Save();

                try
                {
                    TransCollection transCollection = new TransCollection();
                    Trans = transCollection.AddNew();
                    //Trans.KaCode = (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedItem.Value;
                    Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value;
                    Trans.TransNumber = autonumber.ToUpper();
                    Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text;
                    //Trans.Amount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value - (userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value);
                    Trans.DebitAmount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value);
                    Trans.CreditAmount = Convert.ToDecimal((userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value);
                    Trans.Descript = (userControl.FindControl("txtDESC") as RadTextBox).Text;
                    Trans.KasId = (userControl.FindControl("cmbKasID") as RadComboBox).SelectedValue.ToUpper();
                    Trans.TransDate = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate;
                    Trans.UserInsert = "toro";
                    Trans.TglInsert = DateTime.Now;
                    Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"];
                    Trans.Isverified = false;
                    Trans.IsClosed = false;

                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        anCollection.Save();
                        transCollection.Save();
                        scope.Complete();
                    }  
                }
                catch (Exception ex)
                {
                    string es = ex.Message;
                }
                finally
                {
                    RadGrid1.Rebind();
                }
            }
            else
                foreach (AutoNumbering aa in anColl)
                {
                    string i = (aa.LastNumber + 1).ToString().Trim();
                    if (i.Length == 1)
                        autonumber = String.Format("{0}{1}{2}-000{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 2)
                        autonumber = String.Format("{0}{1}{2}-00{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 3)
                        autonumber = String.Format("{0}{1}{2}-0{3}", autonumber, aa.KaYea 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Binary.BinaryResponse类代码示例发布时间:2022-05-24
下一篇:
C# Interfaces.esProviderSpecificMetadata类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap