Exemplo n.º 1
0
        public StoreManagerDBEntities GetContext()
        {
            StoreManagerDBEntities ctx = new StoreManagerDBEntities(ConfigurationManager
                                                                    .ConnectionStrings["StoreManagerDBEntities"].ToString());

            return(ctx);
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        //#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();
            }
        }
Exemplo n.º 4
0
 public ErrorLogRepository()
 {
     ctx = new Connection().GetContext();;
 }
Exemplo n.º 5
0
 protected virtual void DisposeContext()
 {
     //ctx.Dispose();
     ctx = null;
 }
Exemplo n.º 6
0
 protected virtual void initializeContext()
 {
     //this.ctx = new StoreManagerDBEntities();
     this.ctx       = new Connection().GetContext();
     this.objectSet = ctx.CreateObjectSet <TEntity>();
 }
Exemplo n.º 7
0
        public StoreManagerDBEntities GetContext()
        {
            StoreManagerDBEntities ctx = new StoreManagerDBEntities();

            return(ctx);
        }