示例#1
0
 public Brand Get(Expression <Func <Brand, bool> > filter)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         return(context.Set <Brand>().SingleOrDefault(filter));
     }
 }
示例#2
0
 public List <Brand> GetAll(Expression <Func <Brand, bool> > filter = null)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         return(filter == null?context.Set <Brand>().ToList()
                    : context.Set <Brand>().Where(filter).ToList());
     }
 }
示例#3
0
 public Color Get(Expression <Func <Color, bool> > filter)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         //contexti set ediyor color türünde sonra singleOrDefault içinde filtreye göre veriyi getiriyor ;)
         return(context.Set <Color>().SingleOrDefault(filter));
     }
 }
示例#4
0
 public void Update(Brand entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#5
0
 public List <Car> GetAll(Expression <Func <Car, bool> > filter = null)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         //select*from product döndürüyor alttaki kod ve listeye çeviriyor
         return(filter == null?context.Set <Car>().ToList()
                    : context.Set <Car>().Where(filter).ToList());
     }
 }
示例#6
0
 public void Delete(Car entity)
 {
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
示例#7
0
 public void Add(Car entity)
 {
     // IDisposable pattern implementation of c#
     using (ReCapProjectContext context = new ReCapProjectContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }