本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例9: Repository_Provides_New_Batch
public void Repository_Provides_New_Batch()
{
var repo = new InMemoryRepository<Order, int>();
IBatch<Order> batch = repo.BeginBatch();
batch.ShouldNotBeNull();
}