Beispiel #1
0
        public OperationResponse <T> Update(T oEntity)
        {
            OperationResponse <T> Op = new OperationResponse <T>();

            try
            {
                if (oEntity == null)
                {
                    throw new ArgumentNullException("oEntity");
                }
                DbSet <T> dbSet = _dbContext.Set <T>();
                dbSet.Attach(oEntity);
                _dbContext.Entry(oEntity).State = EntityState.Modified;
                int returnValue = _dbContext.SaveChanges();
                Op.Data = returnValue > 0 ? oEntity : default(T);
            }
            catch (Exception ex)
            {
                Op.Message = ex.Message;
            }
            return(Op);
        }