private static Dictionary <RegionNameConfig, RegionIdConfig> GetRegionMap(UserConnection userConnection, List <QueryParameter> regions) { var map = new Dictionary <RegionNameConfig, RegionIdConfig>(); if (!regions.Any()) { return(map); } var select = new Select(userConnection).Distinct() .Column("Country", "Name").As("CountryName") .Column("Country", "Id").As("CountryId") .Column("Region", "Name").As("RegionName") .Column("Region", "Id").As("RegionId") .From("Region") .LeftOuterJoin("Country").On("Country", "Id").IsEqual("Region", "CountryId") .Where("Region", "Name").In(regions.Distinct()); using (DBExecutor dbConnection = userConnection.EnsureDBConnection()) { using (IDataReader reader = dbConnection.ExecuteReader(select.GetSqlText(), select.Parameters)) { while (reader.Read()) { var regionName = reader.GetColumnValue <string>("RegionName"); var countryName = reader.GetColumnValue <string>("CountryName"); var regionId = reader.GetColumnValue <Guid>("RegionId"); var countryId = reader.GetColumnValue <Guid>("CountryId"); var regionNameConfig = new RegionNameConfig(regionName, countryName); if (map.ContainsKey(regionNameConfig)) { continue; } map[regionNameConfig] = new RegionIdConfig(regionId, countryId); } } } return(map); }
public CityIdConfig(Guid city, Guid region, Guid country) : this() { CityId = city; RegionIdConfig = new RegionIdConfig(region, country); }