private void load(List <FieldMatch> fields) { if (fields.Count == 0 && _loadGeom == false) { return; } // размер блока для загрузки в БД int rowsInSect = Math.Min(100, Math.Max(1, RowsCount / 10)); // список параметров для загрузки в БД List <Interfaces.Params>[] paramList = new List <Interfaces.Params> [rowsInSect]; // названия колонок таблицы List <String> columns = new List <string>(); string wktTo = GetSRText(_pgTable.Srid); string wktFrom = GetSRText(_srid); //инициируем считывание _shpWork.StartRead(); List <string> errors = new List <string>(); using (var sw = new SqlWork(_connect, true)) { sw.BeginTransaction(); sw.sql = FormQuerySQL(fields, ref paramList, ref columns); for (int i = 0, report = 0; _shpWork.Read() && report < RowsCount; report++) { //добавляем в таблицу for (int j = 0; j < columns.Count; j++) { try { if (_loadGeom == true && j == columns.Count - 1) { ImporterHelper.SetParamValue( paramList[i][j], _shpWork.TransformedCurrentGeometry(wktTo, wktFrom)); } else { ImporterHelper.SetParamValue( paramList[i][j], _shpWork[columns[j]]); } } catch (Exception e) { if (!errors.Contains(e.Message)) { errors.Add(e.Message); } } } if (++i >= rowsInSect || report == RowsCount - 1) { //кладем в базу for (int k = 0; k < i; k++) { try { sw.ExecuteNonQuery(paramList[k].ToArray()); } catch (Exception e) { if (!errors.Contains(e.Message)) { errors.Add(e.Message); } } } i = 0; ReportProgress(0, report); } } _shpWork.EndRead(); sw.EndTransaction(); if (errors.Count > 0) { throw new Exception(String.Join(Environment.NewLine, errors)); } } }