コード例 #1
0
        public void AddLogToDb(Log log)
        {
            DbContext.Add(log);

            try
            {
                DbContext.SaveChanges();
            }
            catch (DbUpdateException exception)
            {
                if (exception.InnerException != null)
                {
                    throw exception.InnerException;
                }

                throw;
            }
        }
コード例 #2
0
        public async Task <TEntity> CreateAsync(TEntity entity)
        {
            DbContext.Add(entity);

            try
            {
                await DbContext.SaveChangesAsync();
            }
            catch (DbUpdateException exception)
            {
                if (exception.InnerException != null)
                {
                    throw exception.InnerException;
                }

                throw;
            }

            return(entity);
        }