コード例 #1
0
        public async virtual Task UpdateAsync(TModel model)
        {
            var entityToUpdate = await GetAsync(model.Id);

            if (entityToUpdate == null)
            {
                throw new DbUpdateException($"Cannot update item: specified item id: {model.Id} does not exist.");
            }

            Context.Entry(entityToUpdate).CurrentValues.SetValues(model);
            await Context.SaveChangesAsync();
        }