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