public StoreManagerDBEntities GetContext() { StoreManagerDBEntities ctx = new StoreManagerDBEntities(ConfigurationManager .ConnectionStrings["StoreManagerDBEntities"].ToString()); return(ctx); }
public void UpdateProductLocation(ProductLocation entity) { using (StoreManagerDBEntities ctx = new StoreManagerDBEntities()) { ProductLocation loc = ctx.ProductLocations.Where(p => p.Id == entity.Id).FirstOrDefault(); ctx.ProductLocations.Attach(loc); //ctx.ProductLocations.ApplyCurrentValues(entity); ctx.SaveChanges(); } }
//#region IRepository<Brand> Members //public Brand GetById(int id) //{ // using (StoreManagerDBEntities ctx = conn.GetContext()) // { // var brand = ctx.Brands.Where(x => x.BrandID == id).FirstOrDefault(); // return brand; // } //} //public List<Brand> GetAll() //{ // using (StoreManagerDBEntities ctx = conn.GetContext()) // { // var brand = (from b in ctx.Brands // select b).ToList(); // return brand; // } //} public void UpdateBrand(Brand entity) { using (StoreManagerDBEntities ctx = conn.GetContext()) { ctx.Brands.Attach(new Brand { BrandID = entity.BrandID }); //ctx.Brands.ApplyCurrentValues(entity); ctx.SaveChanges(); ctx.Brands.Attach(entity); ObjectStateEntry o = ctx.ObjectStateManager.GetObjectStateEntry(entity); o.ChangeState(System.Data.EntityState.Modified); ctx.SaveChanges(); } }
public ErrorLogRepository() { ctx = new Connection().GetContext();; }
protected virtual void DisposeContext() { //ctx.Dispose(); ctx = null; }
protected virtual void initializeContext() { //this.ctx = new StoreManagerDBEntities(); this.ctx = new Connection().GetContext(); this.objectSet = ctx.CreateObjectSet <TEntity>(); }
public StoreManagerDBEntities GetContext() { StoreManagerDBEntities ctx = new StoreManagerDBEntities(); return(ctx); }