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()); } }
public Brand Get(Expression <Func <Brand, bool> > filter) { using (ReCapDemoDatabaseContext context = new ReCapDemoDatabaseContext()) { return(context.Set <Brand>().SingleOrDefault(filter)); } }
public void Update(Brand entity) { using (ReCapDemoDatabaseContext context = new ReCapDemoDatabaseContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(Brand entity) { using (ReCapDemoDatabaseContext context = new ReCapDemoDatabaseContext()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Brand entity) { using (ReCapDemoDatabaseContext context = new ReCapDemoDatabaseContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }