Exemple #1
0
        public virtual async Task AddRangeAsync(IEnumerable <TEntity> obj)
        {
            try
            {
                _context.ChangeTracker.LazyLoadingEnabled       = false;
                _context.ChangeTracker.QueryTrackingBehavior    = QueryTrackingBehavior.NoTracking;
                _context.ChangeTracker.AutoDetectChangesEnabled = false;

                await _context.BulkInsertAsync(obj.ToList());
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_context.Set <TEntity>().Any())
                {
                    return;
                }
                else
                {
                    throw;
                }
            }
        }