当前位置: 首页>>代码示例>>C#>>正文


C# Company.Create方法代码示例

本文整理汇总了C#中Company.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Company.Create方法的具体用法?C# Company.Create怎么用?C# Company.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Company的用法示例。


在下文中一共展示了Company.Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExplicitFlushInsideSecondTransactionProblem

        public void ExplicitFlushInsideSecondTransactionProblem()
        {
            var comp1 = new Company("comp1");
            var comp2 = new Company("comp2");
            using(new SessionScope())
            {
                comp1.Create();
                comp2.Create();
            }

            using(new SessionScope(FlushAction.Never))
            {
                using(var tx = new TransactionScope(ondispose: OnDispose.Rollback))
                {
                    var comp2a = Company.Find(comp2.Id);
                    comp2a.Name = "changed";
                    tx.VoteCommit();
                }

                using(var scope = new TransactionScope(ondispose: OnDispose.Rollback))
                {
                    var changedCompanies = AR.FindAllByProperty<Company>("Name", "changed");
                    Assert.AreEqual(1, changedCompanies.Count());
                    var e2a = changedCompanies.First();
                    e2a.Delete();

                    scope.Flush();

                    Assert.AreEqual(0, AR.FindAllByProperty<Company>("Name", "changed").Count());
                }
            }
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:32,代码来源:TransactionScopeTestCase.cs

示例2: Main

		public static void Main()
		{
			ActiveRecordStarter.Initialize( 
				new XmlConfigurationSource("../appconfig.xml"), 
				typeof(Company), typeof(Client), typeof(Firm), typeof(Person) );

			// If you want to let AR to create the schema

			ActiveRecordStarter.CreateSchema();

			// Common usage

			Client.DeleteAll();
			Firm.DeleteAll();
			Company.DeleteAll();

			using(new SessionScope())
			{
				Company company = new Company("Stronghold");
				company.Create();

				Firm firm = new Firm("Johnson & Norman");
				firm.Create();

				Client client = new Client("hammett", firm);
				client.Create();
			}

			// Now let's load

			using(new SessionScope())
			{
				Company[] companies = Company.FindAll();
				Debug.Assert(companies.Length == 3);

				Firm[] firms = Firm.FindAll();
				Debug.Assert(firms.Length == 1);

				Client[] clients = Client.FindAll();
				Debug.Assert(clients.Length == 1);

			}

			// Drop the schema if you want
			// ActiveRecordStarter.DropSchema();
		}
开发者ID:ralescano,项目名称:castle,代码行数:46,代码来源:App.cs

示例3: ReportedProblemOnForum

        public void ReportedProblemOnForum()
        {
            using(new TransactionScope())
            {
                var comp1 = new Company("comp1");
                comp1.Create();

                var comp2 = new Company("comp2");
                comp2.Create();
            }
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:11,代码来源:TransactionScopeTestCase.cs


注:本文中的Company.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。