本文整理汇总了C#中InMemoryRepository.Update方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryRepository.Update方法的具体用法?C# InMemoryRepository.Update怎么用?C# InMemoryRepository.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryRepository
的用法示例。
在下文中一共展示了InMemoryRepository.Update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SharpRepository_Supports_Basic_Crud_Operations
public void SharpRepository_Supports_Basic_Crud_Operations()
{
// Declare your generic InMemory Repository.
// Check out HowToAbstractAwayTheGenericRepository.cs for cleaner ways to new up a repo.
var repo = new InMemoryRepository<Order, int>();
// Create
var create = new Order { Name = "Big sale" };
repo.Add(create);
const int expectedOrderId = 1;
create.OrderId.ShouldEqual(expectedOrderId);
// Read
var read = repo.Get(expectedOrderId);
read.Name.ShouldEqual(create.Name);
// Update
read.Name = "Really big sale";
repo.Update(read);
var update = repo.Get(expectedOrderId);
update.OrderId.ShouldEqual(expectedOrderId);
update.Name.ShouldEqual(read.Name);
// Delete
repo.Delete(update);
var delete = repo.Get(expectedOrderId);
delete.ShouldBeNull();
}
示例2: UpdateTest
public void UpdateTest()
{
var repository = new InMemoryRepository<ComplexTestClass>(x => x.ID);
var obj = new ComplexTestClass() { IntValue = 1 };
repository.Insert(obj);
repository.SaveChanges();
repository.Update(new { IntValue = 2 }, obj.ID);
repository.SaveChanges();
var val = repository.Find(obj.ID).Object;
Assert.AreEqual(2, val.IntValue);
var updateObj = new { DateTimeValue = DateTime.MaxValue };
repository.Update(updateObj, x => x.ComplexProperty, obj.ID);
repository.SaveChanges();
Assert.AreEqual(val.ComplexProperty.DateTimeValue, DateTime.MaxValue);
}
示例3: Second_Get_Call_Should_Get_New_Item_From_Cache
public void Second_Get_Call_Should_Get_New_Item_From_Cache()
{
var repository = new InMemoryRepository<Contact, int>(new TimeoutCachingStrategy<Contact, int>(10) { CachePrefix = "#RepoTimeoutCache"});
repository.Add(new Contact() { Name = "Test User"});
var item = repository.Get(1); // after this call it's in cache
item.Name.ShouldEqual("Test User");
repository.Update(new Contact() { ContactId = 1, Name = "Test User EDITED" }); // does update cache
var item2 = repository.Get(1); // should get from cache since the timeout hasn't happened
item2.Name.ShouldEqual("Test User EDITED");
}
示例4: Logging_Via_Aspects
public void Logging_Via_Aspects()
{
var repository = new InMemoryRepository<Contact, int>();
var contact1 = new Contact() {Name = "Contact 1"};
repository.Add(contact1);
repository.Add(new Contact() { Name = "Contact 2"});
repository.Add(new Contact() { Name = "Contact 3"});
contact1.Name += " EDITED";
repository.Update(contact1);
repository.Delete(2);
repository.FindAll(x => x.ContactId < 50);
}