public virtual async Task <bool> AddOrEditAndSaveAsyn(T entity)//添加或者编辑数据 { var dbSet = _entitiesContext.Set <T>(); var hasInstance = await dbSet.AnyAsync(x => x.ID == entity.ID); if (hasInstance) { dbSet.Update(entity); } else { await dbSet.AddAsync(entity); } try { await _entitiesContext.SaveChangesAsync(); return(true); } catch (DbUpdateException) { return(false); } }
public virtual async Task <bool> SaveAsyn() { await _entitiesContext.SaveChangesAsync(); return(true); }