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


C# InMemoryRepository.BeginBatch方法代码示例

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


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

示例1: Batch_Is_IDisposable_Type

 public void Batch_Is_IDisposable_Type()
 {
     var repo = new InMemoryRepository<Order, int>();
     using (var batch = repo.BeginBatch())
     {
         batch.ShouldNotBeNull();
     }
 }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:8,代码来源:HowToBatch.cs

示例2: Batch_Default_Should_Contain_No_Actions

        public void Batch_Default_Should_Contain_No_Actions()
        {
            var repository = new InMemoryRepository<Contact, Int32>();

            using (var batch = repository.BeginBatch())
            {
                batch.BatchActions.Count.ShouldEqual(0);
            }
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:9,代码来源:BatchTests.cs

示例3: Batch_Rollback_Should_Reset_Actions

        public void Batch_Rollback_Should_Reset_Actions()
        {
            var repository = new InMemoryRepository<Contact, Int32>();

            using (var batch = repository.BeginBatch())
            {
                batch.Add(new Contact());
                batch.Rollback();
                batch.BatchActions.Count.ShouldEqual(0);
            }
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:11,代码来源:BatchTests.cs

示例4: Batch_Can_Be_Disregarded

        public void Batch_Can_Be_Disregarded()
        {
            var repo = new InMemoryRepository<Order, int>();

            using (var batch = repo.BeginBatch())
            {
                batch.Add(new Order { Name = "Order 1" });
                batch.Add(new Order { Name = "Order 2" });
            }

            repo.GetAll().Count().ShouldEqual(0);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:12,代码来源:HowToBatch.cs

示例5: Batch_Update_Should_Queue_Delete_Action

        public void Batch_Update_Should_Queue_Delete_Action()
        {
            var repository = new InMemoryRepository<Contact, Int32>();

            using (var batch = repository.BeginBatch())
            {
                var contact = new Contact();
                batch.Delete(contact);
                batch.BatchActions.FirstOrDefault().Item.ShouldEqual(contact);
                batch.BatchActions.FirstOrDefault().Action.ShouldEqual(BatchAction.Delete);
            }
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:12,代码来源:BatchTests.cs

示例6: Add_Operations_Can_Be_Batched

        public void Add_Operations_Can_Be_Batched()
        {
            var repo = new InMemoryRepository<Order, int>();

            using (var batch = repo.BeginBatch())
            {
                batch.Add(new Order { Name = "Order 1" });
                batch.Add(new Order { Name = "Order 2" });
                repo.GetAll().Count().ShouldEqual(0);

                batch.Commit();
            }

            repo.GetAll().Count().ShouldEqual(2);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:15,代码来源:HowToBatch.cs

示例7: Repository_Should_BeginBatch

        public void Repository_Should_BeginBatch()
        {
            var repository = new InMemoryRepository<Contact, Int32>();

            using (var batch = repository.BeginBatch())
            {
                batch.Add(new Contact { Name = "Test User 1" });

                var result = repository.GetAll();
                result.Count().ShouldEqual(0); // shouldn't have really been added yet

                batch.Add(new Contact { Name = "Test User 2" });

                result = repository.GetAll();
                result.Count().ShouldEqual(0); // shouldn't have really been added yet

                batch.Commit();
            }

            repository.GetAll().Count().ShouldEqual(2);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:21,代码来源:BatchSpike.cs

示例8: Update_Operations_Can_Be_Batched

        public void Update_Operations_Can_Be_Batched()
        {
            var repo = new InMemoryRepository<Order, int>();
            repo.Add(new Order { Name = "Order 1" });
            repo.Add(new Order { Name = "Order 2" });
            repo.GetAll().Count().ShouldEqual(2);

            using (var batch = repo.BeginBatch())
            {
                foreach (var order in repo.GetAll())
                {
                    order.Name = "Updated";
                    batch.Update(order);
                }

                repo.GetAll().Count().ShouldEqual(2);
                repo.GetAll().Count(x => x.Name.StartsWith("Update")).ShouldEqual(0);

                batch.Commit();
            }

            repo.GetAll().Count().ShouldEqual(2);
            repo.GetAll().Count(x => x.Name.StartsWith("Update")).ShouldEqual(2);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:24,代码来源:HowToBatch.cs

示例9: Repository_Provides_New_Batch

 public void Repository_Provides_New_Batch()
 {
     var repo = new InMemoryRepository<Order, int>();
     IBatch<Order> batch = repo.BeginBatch();
     batch.ShouldNotBeNull();
 }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:6,代码来源:HowToBatch.cs


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