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


C# RepositoryFactory.Add方法代码示例

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


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

示例1: AddTest

 public void AddTest()
 {
     var clientRepo = new RepositoryFactory<IClientRepository>().ResolveRepository();
     var count = clientRepo.All().Count();
      clientRepo.Add(new Client{Name="UNITTEST",Description = "UNITTEST"});
     clientRepo.UnitOfWork.Commit();
      Assert.IsTrue(count + 1 == new RepositoryFactory<IClientRepository>().ResolveRepository().All().Count());
 }
开发者ID:badwah,项目名称:Spinn,代码行数:8,代码来源:ClientRepositoryTest.cs

示例2: Can_Save_New_Customer_With_Orders_And_Details

        public void Can_Save_New_Customer_With_Orders_And_Details()
        {
            var customer = GetCustomer();

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
                Assert.IsNotNull(cust);
                CollectionAssert.IsNotEmpty(cust.Orders);
                Assert.IsNotNull(cust.Orders.First(o => o.OrderDetail != null).OrderDetail);
            }
        }
开发者ID:Mir4ik,项目名称:TestRepo,代码行数:18,代码来源:EntiyFrameworkTests.cs

示例3: Can_Use_UoW_To_Remove_And_Add_Customer_In_A_Transaction

        public void Can_Use_UoW_To_Remove_And_Add_Customer_In_A_Transaction()
        {
            using (var uow = new MegaEntityFrameworkUnitOfWorkFactory().Create())
            {
                var repo = new RepositoryFactory().Create(uow);
                var c1 = repo.All<Customer>().Single(c => c.Email == "[email protected]");
                repo.Delete(c1);
                var c2 = GetCustomer();
                repo.Add(c2);
                uow.Commit();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var x = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
                Assert.IsNull(x);
                var y = repo.All<Customer>().Any(c => c.Country == "Italy");
                Assert.IsTrue(y);
            }
        }
开发者ID:Mir4ik,项目名称:TestRepo,代码行数:20,代码来源:EntiyFrameworkTests.cs

示例4: Can_Save_New_Customer

        public void Can_Save_New_Customer()
        {
            var customer = new Customer
            {
                ContactName = "johnny",
                Email = "[email protected]"
            };

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
                Assert.IsNotNull(cust);
            }
        }
开发者ID:Mir4ik,项目名称:TestRepo,代码行数:20,代码来源:EntiyFrameworkTests.cs


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