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


C# InMemoryRepository.Update方法代码示例

本文整理汇总了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();
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:30,代码来源:GettingStarted.cs

示例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);
        }
开发者ID:simran2jain,项目名称:Repository,代码行数:19,代码来源:Tests.cs

示例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");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:14,代码来源:TimeoutCachingStrategyTests.cs

示例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);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:16,代码来源:LoggingSpikes.cs


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