public virtual DeleteResult Delete(TKey id)
 {
     return(ReferenceChecker
            .Check(id)
            .OnDelete(() =>
     {
         Set.FindOptional(id)
         .MatchSome(entity =>
         {
             Set.Remove(entity);
             Context.SaveChanges();
         });
     }));
 }
Exemple #2
0
 public DeleteResult Delete(long id)
 {
     return(ReferenceChecker
            .Check(id)
            .OnDelete(() =>
     {
         Context.Files
         .FindOptional(id)
         .MatchSome(file =>
         {
             TransactionManager.DoInTransaction(() =>
             {
                 var binary = Context.Binaries.Single(x => x.FileId == file.Id);
                 Context.Binaries.Remove(binary);
                 Context.Files.Remove(file);
                 Context.SaveChanges();
             });
         });
     }));
 }
 public BaseRepository(TContext context)
 {
     Context          = context;
     ReferenceChecker = new ReferenceChecker <TKey>(context);
 }