示例#1
0
        public virtual async Task <TEntity> UpdateAsync(TEntity entity, object key)
        {
            if (entity == null)
            {
                return(null);
            }

            TEntity exist = await context.Set <TEntity>().FindAsync(key);

            if (exist != null)
            {
                context.Entry(exist).CurrentValues.SetValues(entity);
                await context.SaveChangesAsync();
            }
            return(exist);
        }
        //public int SaveChages()
        //{
        //    return context.SaveChanges();
        //}

        public Task <int> SaveChangesAsync()
        {
            return(context.SaveChangesAsync());
        }