Exemple #1
0
 public List <Car> GetAll(Expression <Func <Car, bool> > filter = null)
 {
     using (RentACarContext context = new RentACarContext())
     {
         return(filter == null?context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList());
     }
 }
Exemple #2
0
 public Car Get(Expression <Func <Car, bool> > filter)
 {
     using (RentACarContext context = new RentACarContext())
     {
         return(context.Set <Car>().SingleOrDefault(filter));
     }
 }
Exemple #3
0
 public void Update(Car entity)
 {
     using (RentACarContext context = new RentACarContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemple #4
0
 public void Delete(Car entity)
 {
     using (RentACarContext context = new RentACarContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemple #5
0
 public void Add(Car entity)
 {
     using (RentACarContext context = new RentACarContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
 public void Update(Brand entity)
 {
     using (RentACarContext context = new RentACarContext())
     {
         var updatedEntity = context.Entry(entity);  //referansı yakala,veri kaynağıyla ilişkilendir
         updatedEntity.State = EntityState.Modified; // o aslında güncellenecek  bir nesne
         context.SaveChanges();
     }
 }
 public void Delete(Brand entity)
 {
     using (RentACarContext context = new RentACarContext())
     {
         var deletedEntity = context.Entry(entity); //referansı yakala,veri kaynağıyla ilişkilendir
         deletedEntity.State = EntityState.Deleted; // o aslında silinecek bir nesne
         context.SaveChanges();
     }
 }