本文整理汇总了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);
}
}
示例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);
}
}
});
}
示例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());
}
示例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());
}
示例5: CacheModule
public CacheModule(IRepository repository)
{
Get["/api/pull/clear/transactions"] = _ =>
{
repository.Delete<Transaction>();
return View["/"];
};
}
示例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++;
}
示例7: CampaignCategoriesHandler
public CampaignCategoriesHandler(IRepository<CampaignCategoriesRecord> repository)
{
Filters.Add(StorageFilter.For(repository));
OnRemoved<CampaignCategoriesPart>((context, part) =>
{
repository.Delete(part.Record);
});
}
示例8: MailChimpSettingsPartHandler
public MailChimpSettingsPartHandler(IRepository<MailChimpSettingsPartRecord> repository)
{
Filters.Add(StorageFilter.For(repository));
OnRemoved<MailChimpSettingsPart>((context, part) =>
{
repository.Delete(part.Record);
});
}
示例9: FaqEntryPartHandler
public FaqEntryPartHandler(IRepository<FaqEntryPartRecord> repository)
{
Filters.Add(StorageFilter.For(repository));
OnRemoved<FaqEntryPart>((context, part) =>
{
repository.Delete(part.Record);
});
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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);
}
}