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

                return(result);
            }
        }