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


C# IRepository.Delete方法代码示例

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


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

示例1: RecoveryController

        public RecoveryController(
            IRepository<Post> postRepository,
            IRepository<Redirect> redirectRepository,
            IRepository<BlogTemplate> styleRepository,
            IRepository<User> userRepository,
            IRepository<Securable> securableRepository,
            IRepository<TemporaryUploadedBlogBackup> tempBlogBackupRepo,
            IRepository<Data.Blog> blogRepository,
            ISecurityHelper securityHelper,
            IHttpContextService httpContext)
            : base(blogRepository, httpContext, securityHelper, userRepository, securableRepository)
        {
            _postRepository = postRepository;
            _redirectRepository = redirectRepository;
            _styleRepository = styleRepository;
            _tempBlogBackupRepo = tempBlogBackupRepo;
            _userRepository = userRepository;
            _blogRepository = blogRepository;
            _securityHelper = securityHelper;

            //Naieve clean of the collection to avoid leaks in long running instances of the application
            var toDelete = _tempBlogBackupRepo.GetAll().Where(b => b.UploadTime < DateTime.Now.AddHours(-1)).ToArray();
            foreach(var toDel in toDelete)
            {
                _tempBlogBackupRepo.Delete(toDel);
            }
        }
开发者ID:rajeshpillai,项目名称:StaticVoid.Blog,代码行数:27,代码来源:RecoveryController.cs

示例2: 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

示例3: FaqTypeHandler

        public FaqTypeHandler(IRepository<FaqTypePartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
            OnRemoved<FaqTypePart>((context, part) => repository.Delete(part.Record));
            OnIndexing<FaqTypePart>((context, contactPart) => context.DocumentIndex.Add("faqtype_title", contactPart.Title).Analyze().Store());

        }
开发者ID:BelitsoftLLC,项目名称:orchard-faq,代码行数:7,代码来源:FaqTypeHandler.cs

示例4: FaqHandler

        public FaqHandler(IRepository<FaqPartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
            OnRemoved<FaqPart>((context, part) => repository.Delete(part.Record));

            OnIndexing<FaqPart>((context, contactPart) => context.DocumentIndex.Add("faq_question", contactPart.Question).Analyze().Store());
        }
开发者ID:BelitsoftLLC,项目名称:orchard-faq,代码行数:7,代码来源:FaqHandler.cs

示例5: CacheModule

 public CacheModule(IRepository repository)
 {
     Get["/api/pull/clear/transactions"] = _ =>
     {
         repository.Delete<Transaction>();
         return View["/"];
     };
 }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:8,代码来源:CacheModule.cs

示例6: RecalculateBlogArchive

        private void RecalculateBlogArchive(IRepository<BlogPartArchiveRecord> blogArchiveRepository, BlogPostPart blogPostPart) {
            blogArchiveRepository.Flush();
            
            var commonPart = blogPostPart.As<CommonPart>();
                if(commonPart == null || !commonPart.CreatedUtc.HasValue)
                    return;

            // get the time zone for the current request
            var timeZone = _workContextAccessor.GetContext().CurrentTimeZone;

            var previousCreatedUtc = _previousCreatedUtc.ContainsKey(blogPostPart) ? _previousCreatedUtc[blogPostPart] : DateTime.MinValue;
            previousCreatedUtc = TimeZoneInfo.ConvertTimeFromUtc(previousCreatedUtc, timeZone);

            var previousMonth = previousCreatedUtc.Month;
            var previousYear = previousCreatedUtc.Year;

            var newCreatedUtc = commonPart.CreatedUtc;
            newCreatedUtc = newCreatedUtc.HasValue ? TimeZoneInfo.ConvertTimeFromUtc(newCreatedUtc.Value, timeZone) : newCreatedUtc;

            var newMonth = newCreatedUtc.HasValue ? newCreatedUtc.Value.Month : 0;
            var newYear = newCreatedUtc.HasValue ? newCreatedUtc.Value.Year : 0;

            // if archives are the same there is nothing to do
            if (previousMonth == newMonth && previousYear == newYear) {
                return;
            }
            
            // decrement previous archive record
            var previousArchiveRecord = blogArchiveRepository.Table
                .Where(x => x.BlogPart == blogPostPart.BlogPart.Record
                    && x.Month == previousMonth
                    && x.Year == previousYear)
                .FirstOrDefault();

            if (previousArchiveRecord != null && previousArchiveRecord.PostCount > 0) {
                previousArchiveRecord.PostCount--;
            }

            // if previous count is now zero, delete the record
            if (previousArchiveRecord != null && previousArchiveRecord.PostCount == 0) {
                blogArchiveRepository.Delete(previousArchiveRecord);
            }
            
            // increment new archive record
            var newArchiveRecord = blogArchiveRepository.Table
                .Where(x => x.BlogPart == blogPostPart.BlogPart.Record
                    && x.Month == newMonth
                    && x.Year == newYear)
                .FirstOrDefault();

            // if record can't be found create it
            if (newArchiveRecord == null) {
                newArchiveRecord = new BlogPartArchiveRecord { BlogPart = blogPostPart.BlogPart.Record, Year = newYear, Month = newMonth, PostCount = 0 };
                blogArchiveRepository.Create(newArchiveRecord);
            }

            newArchiveRecord.PostCount++;            
        }
开发者ID:kerrjon,项目名称:MNFathers,代码行数:58,代码来源:BlogPartArchiveHandler.cs

示例7: CampaignCategoriesHandler

        public CampaignCategoriesHandler(IRepository<CampaignCategoriesRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));

            OnRemoved<CampaignCategoriesPart>((context, part) =>
            {
                repository.Delete(part.Record);
            });
        }
开发者ID:omidam81,项目名称:Ver1.0,代码行数:9,代码来源:CampaignCategoriesHandler.cs

示例8: MailChimpSettingsPartHandler

        public MailChimpSettingsPartHandler(IRepository<MailChimpSettingsPartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));

            OnRemoved<MailChimpSettingsPart>((context, part) =>
            {
                repository.Delete(part.Record);
            });
        }
开发者ID:omidam81,项目名称:Ver1.0,代码行数:9,代码来源:MailChimpSettingsPartHandler.cs

示例9: FaqEntryPartHandler

        public FaqEntryPartHandler(IRepository<FaqEntryPartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));

            OnRemoved<FaqEntryPart>((context, part) =>
            {
                repository.Delete(part.Record);
            });
        }
开发者ID:omidam81,项目名称:Ver1.0,代码行数:9,代码来源:FaqEntryPartHandler.cs

示例10: Delete

 public void Delete(int id)
 {
     DAL.DataEntities.Configuration DALConfiguration;
     using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
     {
         DALConfiguration = _ConfigurationRepository.SingleOrDefault(m => m.ID == id);
         _ConfigurationRepository.Delete(DALConfiguration);
         _ConfigurationRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:10,代码来源:ConfigurationService.cs

示例11: Delete

 public void Delete(int id)
 {
     DAL.DataEntities.Model model;
     using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
     {
         model = _ModelRepository.SingleOrDefault(m => m.ID == id);
         _ModelRepository.Delete(model);
         _ModelRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:10,代码来源:ModelService.cs

示例12: Delete

 public void Delete(int id)
 {
     DAL.DataEntities.UITemplate template;
     using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
     {
         template = _UITemplateRepository.SingleOrDefault(m => m.ID == id);
         _UITemplateRepository.Delete(template);
         _UITemplateRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:10,代码来源:UITemplateService.cs

示例13: 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

示例14: DeleteTags

 public static void DeleteTags(IRepository<DalTagEntity> repository, int idArticle)
 {
     var tags = repository.GetAll()
         .Where(c => c.Article != null)
         .Where(c => c.Article.Id == idArticle)
         .Select(c => c)
         .ToList();
     foreach (var item in tags)
     {
         repository.Delete(item);
     }
 }
开发者ID:gewandt,项目名称:PersonalBlog,代码行数:12,代码来源:Helper.cs

示例15: DeleteComments

 public static void DeleteComments(IRepository<DalCommentEntity> repository, int idUser)
 {
     var comments = repository.GetAll()
         .Where(c => c.User != null)
         .Where(c => c.User.Id == idUser)
         .Select(c => c)
         .ToList();
     foreach (var item in comments)
     {
         repository.Delete(item);
     }
 }
开发者ID:gewandt,项目名称:PersonalBlog,代码行数:12,代码来源:Helper.cs


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