public ParserMyFin() { db = new Context(); lstBanks = new List<Bank>(); ParseCity(); db.Banks.AddRange(lstBanks); db.SaveChanges(); ParseBanks(); //ParseReviews(); ParseGeo(); //db.Banks.Load(); }
async public void ConvertDepartmentsAddress(string apiConfig) { var xmldocument = new XmlDocument(); try { xmldocument.Load(apiConfig); } catch (Exception) { return; } var apiKey = xmldocument.SelectSingleNode("config/api[@service='googleGeo']/key").InnerText; using (var context = new Context()) { //Code-First defaults: true, DB/ModelFirst - See EDMX Props var query = from department in context.Departments select department; var departmentList = query.ToList(); foreach (var department in departmentList) { PLatLng point; // На каждой итерации обращение к БД!!!! if (department.Address != null && (department.latitude == 0 || department.longitude == 0)) { point = GeoCoding(department.Address, apiKey); if (point != null) { department.latitude = point.Latitude; department.longitude = point.Longitude; await context.SaveChangesAsync(); } } } } }