public List <Product> GetAll(Expression <Func <Product, bool> > filter = null) { using (NortwindContext context = new NortwindContext()) { return(filter == null?context.Set <Product>().ToList() : context.Set <Product>().Where(filter).ToList()); } }
public Product Get(Expression <Func <Product, bool> > filter) { using (NortwindContext context = new NortwindContext()) { return(context.Set <Product>().SingleOrDefault(filter)); } }
//NuGet: Kodların konulup ortak kullanıldığı mekan public void Add(Product entity) { //IDisposable pattern implamentation of c# using (NortwindContext context = new NortwindContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public ProductosController(NortwindContext nortwindContext) { this._nortwindContext = nortwindContext; }
public ProductBusiness(NortwindContext dbContext) { _dbContext = dbContext; }
public CategoryBusiness(NortwindContext dbContext) { _dbContext = dbContext; }