public virtual void Update(TEntity entity)
        {
            var local = _db.Set <TEntity>().Local.FirstOrDefault(f => f.CustomerID == customer.CustomerID);

            if (local != null)
            {
                db.Entry(local).State = EntityState.Detached;
            }
            _dbset.Attach(entity);
            _db.Entry(entity).State = EntityState.Modified;
        }
        public bool UpdateCustomer(Customers customer)
        {
            var local = db.Set <Customers>()
                        .Local
                        .FirstOrDefault(f => f.CustomerID == customer.CustomerID);

            if (local != null)
            {
                db.Entry(local).State = EntityState.Detached;
            }
            db.Entry(customer).State = EntityState.Modified;
            return(true);
        }
Example #3
0
 public bool Update(Customers customer)
 {
     try
     {
         //اگر موقع استفاده از یوزینگ استفاده نکنیم در زمان آپدیت به مشکل می خوردیم که با دی تچ کردن به روش زیر مشکل حل می شود
         var local = db.Set <Customers>().Local.FirstOrDefault(f => f.CustomerID == customer.CustomerID);
         if (local != null)
         {
             db.Entry(local).State = EntityState.Detached;
         }
         //
         db.Entry(customer).State = EntityState.Modified;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public bool UpdateCustomer(Customers customer)
        {
            //try
            //{
            var local = db.Set <Customers>()
                        .Local
                        .FirstOrDefault(f => f.CustomerID == customer.CustomerID);

            if (local != null)
            {
                db.Entry(local).State = EntityState.Detached;
            }
            db.Entry(customer).State = System.Data.Entity.EntityState.Modified;
            return(true);
            //}
            //catch
            //{
            //    return false;
            //}
        }
 public GenericRepository(Accounting_DBEntities db)
 {
     _db    = db;
     _dbSet = _db.Set <TEntity>();
 }
Example #6
0
 public GenericRepository(Accounting_DBEntities db)
 {
     _db    = db;
     _dbset = _db.Set <EntityType>();
 }