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


C# IRepository.Get方法代码示例

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


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

示例1: Delete_Should_Remove_Item_By_Key

        public void Delete_Should_Remove_Item_By_Key(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User" };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId);
            result.ShouldNotBeNull();

            repository.Delete(contact.ContactId);
            result = repository.Get(contact.ContactId);
            result.ShouldBeNull();
        }
开发者ID:belsrc,项目名称:SharpRepository,代码行数:12,代码来源:RepositoryDeleteTests.cs

示例2: OrderShippingPartHandler

        public OrderShippingPartHandler(
            IRepository<OrderShippingPartRecord> repository,
            IRepository<OrderAddressRecord> orderAddressRepository)
        {
            Filters.Add(StorageFilter.For(repository));

            OnActivated<OrderShippingPart>((context, part) => {
                part._shippingDetails.Loader(shippingDetails => {
                    var orderPart = context.ContentItem.As<OrderPart>();
                    if (orderPart != null) {
                        return orderPart.Details.Where(d => d.DetailType == "Shipping");
                    }
                    else {
                        return new List<OrderDetail>();
                    }
                });

                part._shippingAddress.Loader(shippingAddress => orderAddressRepository.Get(part.ShippingAddressId));
            });

            OnCreated<OrderShippingPart>((context, part) => {
                part.ShippingAddressId = orderAddressRepository.CreateOrUpdate(part.ShippingAddress);
            });

            OnUpdated<OrderShippingPart>((context, part) => {
                part.ShippingAddressId = orderAddressRepository.CreateOrUpdate(part.ShippingAddress);
            });
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:28,代码来源:OrderShippingPartHandler.cs

示例3: GiveCampSettings

        public GiveCampSettings()
        {
            repository = new EntityFrameworkRepository();
            var settings = repository.Get<EventSetting>(x => x.Id == DefaultId);

            HttpRuntime.Cache.Insert("Settings", settings, null, DateTime.Now.AddMinutes(10d), System.Web.Caching.Cache.NoSlidingExpiration);
        }
开发者ID:GiveCamp,项目名称:GiveCampStarterSite,代码行数:7,代码来源:GiveCampSettings.cs

示例4: HasTagsHandler

        public HasTagsHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository)
        {
            OnLoading<HasTags>((context, tags) => {

                // provide names of all tags on demand
                tags._allTags.Loader(list => tagsRepository.Table.ToList());

                // populate list of attached tags on demand
                tags._currentTags.Loader(list => {
                    var tagsContentItems = tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id);
                    foreach (var tagContentItem in tagsContentItems) {
                        var tag = tagsRepository.Get(tagContentItem.TagId);
                        list.Add(tag);
                    }
                    return list;
                });

            });

            OnRemoved<HasTags>((context, ht) => {
                tagsContentItemsRepository.Flush();

                HasTags tags = context.ContentItem.As<HasTags>();
                foreach (var tag in tags.CurrentTags) {
                    if (!tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id).Any()) {
                        tagsRepository.Delete(tag);
                    }
                }
            });
        }
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:30,代码来源:HasTagsHandler.cs

示例5: MainAsync

        static async Task MainAsync(IRepository<SampleEntity> repo)
        {
            foreach (var s in await repo.GetAllAsync())
            {
                Console.WriteLine("{0} | {1}", s.ID, s.Name);
            }

            // Paged Set //
            Console.WriteLine("\nPage = 2 - Page Size = 2 :");
            var some = await repo.GetAsync(2, 2, s => s.ID);
            foreach (var s in some)
            {
                Console.WriteLine("{0} | {1}", s.ID, s.Name);
            }
                
            // Updating //
            var fox = await repo.FindAsync(e => e.Name == "Fox");
            fox.Name = "Dog";

            repo.Update(fox, fox.ID);

            // Deleting //
            Console.WriteLine("\n " + await repo.DeleteAsync(repo.Get(5)) + "\n");

            foreach (var e in repo.GetAll())
                Console.WriteLine(e.ID + " | " + e.Name);
        }
开发者ID:ioab,项目名称:.NET-EF6-GenericRepository,代码行数:27,代码来源:Program.cs

示例6: CombineDecisions

        public void CombineDecisions(IAccessDecisionCombinator combinator, IRepository<Role> roleRepository)
        {
            if (_disabled) return;

              foreach (var roleId in _roles) {
            roleRepository.Get(roleId).CombineDecisions(combinator);
              }
        }
开发者ID:yreynhout,项目名称:NAuthorize,代码行数:8,代码来源:User.cs

示例7: Update_Should_Save_Modified_Business_Name

        public void Update_Should_Save_Modified_Business_Name(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User" };
            repository.Add(contact);

            var contact2 = new Contact { Name = "Test User 2" };
            repository.Add(contact2);

            contact.Name = "Test User - Updated";
            repository.Update(contact);

            var updated = repository.Get(contact.ContactId);
            var notUpdated = repository.Get(contact2.ContactId);

            updated.Name.ShouldEqual("Test User - Updated");
            notUpdated.Name.ShouldEqual("Test User 2");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:17,代码来源:RepositoryUpdateTests.cs

示例8: LowHealthUnitsWalkTogetherRule

 public LowHealthUnitsWalkTogetherRule(ComponentService componentService, AIDto ai, IRepository<GameEnvironment> gameEnvironmentRepository, IVector2Service vector2Service, IEventStoreService eventStoreService)
 {
     _componentService = componentService;
     _ai = ai;
     _vector2Service = vector2Service;
     _eventStoreService = eventStoreService;
     _gameEnvironment = gameEnvironmentRepository.Get();
 }
开发者ID:Ostblock,项目名称:Ostzone,代码行数:8,代码来源:LowHealthUnitsWalkTogetherRule.cs

示例9: Get_With_String_Selector_Should_Return_Item_If_Item_Exists

        public void Get_With_String_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User" };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId, c => c.Name);
            result.ShouldEqual("Test User");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:8,代码来源:RepositoryGetTests.cs

示例10: GetPushEventExample

        private static void GetPushEventExample(IRepository<EventPushCampaign> eventPushRepo)
        {
            var e = eventPushRepo.Get(4251);

            Console.WriteLine("Fetched event: {0}", e.Id);
            Console.WriteLine("Channels: {0}", String.Join(", ", e.ChannelIds));
            Console.WriteLine("Targets: {0}", String.Join(", ", e.Targets));
        }
开发者ID:pankhuri3,项目名称:vector370-dotnet,代码行数:8,代码来源:Program.cs

示例11: PeopleViewModel

        public PeopleViewModel(IRepository<Person> repository, IEventAggregator eventAggregator)
        {
            People = new ListCollectionView(repository.Get());

            People.CurrentChanged += new EventHandler(OnSelectedItemChanged);

            this.eventAggregator = eventAggregator;
        }
开发者ID:rhwilson1971,项目名称:PeopleManager,代码行数:8,代码来源:PeopleViewModel.cs

示例12: Get_Should_Return_Item_If_Item_Exists

        public void Get_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User", ContactTypeId = 1 };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId);
            result.Name.ShouldEqual(contact.Name);
            result.ContactTypeId.ShouldEqual(contact.ContactTypeId);
        }
开发者ID:SharpRepository,项目名称:SharpRepository,代码行数:9,代码来源:RepositoryGetTests.cs

示例13: Get_With_Anonymous_Class_Selector_Should_Return_Item_If_Item_Exists

        public void Get_With_Anonymous_Class_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User", ContactTypeId = 2 };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId, c => new { c.ContactTypeId, c.Name });
            result.ContactTypeId.ShouldEqual(2);
            result.Name.ShouldEqual("Test User");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:9,代码来源:RepositoryGetTests.cs

示例14: BuildBarrackRule

 public BuildBarrackRule(ComponentService componentService, AIDto ai, IOrientationService orientationService, IVector2Service vector2Service, IRepository<GameEnvironment> gameEnvironmentRepository, IEventStoreService eventStoreService)
 {
     _componentService = componentService;
     _ai = ai;
     _orientationService = orientationService;
     _vector2Service = vector2Service;
     _eventStoreService = eventStoreService;
     _gameEnvironment = gameEnvironmentRepository.Get();
 }
开发者ID:Ostblock,项目名称:Ostzone,代码行数:9,代码来源:BuildBarrackRule.cs

示例15: Using_TransactionScope_Without_Complete_Should_Not_Add

        public void Using_TransactionScope_Without_Complete_Should_Not_Add(IRepository<Contact, string> repository)
        {
            repository.Get("test"); // used to create the SqlCe database before being inside the transaction scope since that throws an error

            using (var trans = new TransactionScope())
            {
                repository.Add(new Contact {Name = "Contact 1"});
            }

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


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