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