using MySqlConnector; using skyscraper5.Skyscraper.Scraper.Storage.Split; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace skyscraper5.Data.MySql { public partial class MySqlDataStorage : DataStorage { private bool _askedForLocation; private int? _cachedLocation; public int? GetCurrentLocationId() { if (_askedForLocation) return _cachedLocation; int? result = null; using (MySqlConnection connection = new MySqlConnection(_mcsb.ToString())) { connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT id FROM skyscraper_locations WHERE current = TRUE"; MySqlDataReader dataReader = command.ExecuteReader(); if (dataReader.Read()) result = dataReader.GetInt32(0); dataReader.Close(); connection.Close(); } _askedForLocation = true; _cachedLocation = result; return result; } } }