Exemple #1
0
 public List <Book> GetAll(Expression <Func <Book, bool> > filter = null)
 {
     using (BookDatabasesContext context = new BookDatabasesContext())
     {
         return(filter == null?context.Set <Book>().ToList() : context.Set <Book>().Where(filter).ToList());
     }
 }
Exemple #2
0
 public Book Get(Expression <Func <Book, bool> > filter)
 {
     using (BookDatabasesContext context = new BookDatabasesContext())
     {
         return(context.Set <Book>().SingleOrDefault(filter));
     }
 }
 public PublishingHouse Get(Expression <Func <PublishingHouse, bool> > filter)
 {
     using (BookDatabasesContext context = new BookDatabasesContext())
     {
         return(context.Set <PublishingHouse>().SingleOrDefault(filter));
     }
 }
Exemple #4
0
 public void Update(Book entity)
 {
     using (BookDatabasesContext context = new BookDatabasesContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #5
0
 public void Delete(Book entity)
 {
     using (BookDatabasesContext context = new BookDatabasesContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemple #6
0
 public void Add(Book entity)
 {
     using (BookDatabasesContext context = new BookDatabasesContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }