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