Ejemplo n.º 1
0
 public List <Car> GetAll(Expression <Func <Car, bool> > filter = null)
 {
     using (WestwindContext context = new WestwindContext())
     {
         return(filter == null?context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList());
     }
 }
Ejemplo n.º 2
0
 public Car Get(Expression <Func <Car, bool> > filter)
 {
     using (WestwindContext context = new WestwindContext())
     {
         return(context.Set <Car>().SingleOrDefault(filter));
     }
 }
Ejemplo n.º 3
0
 public void Update(Car entity)
 {
     using (WestwindContext context = new WestwindContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void Delete(Car entity)
 {
     using (WestwindContext context = new WestwindContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 public void Add(Car entity)
 {
     // IDisposable pattern implementation c# = araştırılacak usin bittiği anda belleği hızlıca temizle demek
     using (WestwindContext context = new WestwindContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }