Пример #1
0
        public async Task BulkInsert(IList <EventHistory> inserting)
        {
            using (var model = new gb_dvsstagingEntities())
            {
                model.Configuration.AutoDetectChangesEnabled = false;
                model.Configuration.ValidateOnSaveEnabled    = false;
                model.Database.CommandTimeout = CONNECTION_TIMEOUT;


                // will add by counter events
                for (int i = 0; i <= inserting.Count() / INSERT_COUNT; i++)
                {
                    var subHistories = inserting.Skip(i * INSERT_COUNT).Take(INSERT_COUNT).ToList();

                    var histories = subHistories.Select(NewRepositoryEventHistoryFrom).ToList();

                    model.dvs_eventhistory.AddRange(histories);
                    await model.SaveChangesAsync();
                }
            }
        }