예제 #1
0
 public Color Get(Expression <Func <Color, bool> > filter)
 {
     using (CarRentalContex contex = new CarRentalContex())
     {
         var result = contex.Set <Color>().SingleOrDefault(filter);
         return(result);
     }
 }
예제 #2
0
 public void Update(Color entity)
 {
     using (CarRentalContex contex = new CarRentalContex())
     {
         var updatedEntity = contex.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         contex.SaveChanges();
     }
 }
예제 #3
0
 public void Delete(Color entity)
 {
     using (CarRentalContex contex = new CarRentalContex())
     {
         var deletedEntity = contex.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         contex.SaveChanges();
     }
 }
예제 #4
0
 public void Add(Color entity)
 {
     using (CarRentalContex context = new CarRentalContex())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
예제 #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);
            }
        }