public static void WriteQueriesToFiles() { Directory.CreateDirectory(SeedFolderPath); using (var currencyFile = new StreamWriter(CurrencyFilePath)) { currencyFile.WriteLine(SetIdentityInsert(nameof(Currency), true)); currencyFile.WriteLine(CurrencyInsertClause); Currencies.ForEach(currency => currencyFile.WriteLine(currency.Id == 1 ? FormatCurrencyValues(currency) : $"union all {FormatCurrencyValues(currency)}")); currencyFile.WriteLine(SetIdentityInsert(nameof(Currency), false)); } using (var languageFile = new StreamWriter(LanguageFilePath)) { languageFile.WriteLine(SetIdentityInsert(nameof(Language), true)); languageFile.WriteLine(LanguageInsertClause); Languages.ForEach(language => languageFile.WriteLine(language.Id == 1 ? FormatLanguageValues(language) : $"union all {FormatLanguageValues(language)}")); languageFile.WriteLine(SetIdentityInsert(nameof(Language), false)); } using (var countryFile = new StreamWriter(CountryFilePath)) { countryFile.WriteLine(SetIdentityInsert(nameof(Country), true)); countryFile.WriteLine(CountryInsertClause); Countries.ForEach(country => countryFile.WriteLine(country.Id == 1 ? FormatCountryValues(country) : $"union all {FormatCountryValues(country)}")); countryFile.WriteLine(SetIdentityInsert(nameof(Country), false)); } using (var countryLanguageFile = new StreamWriter(CountryLanguageFilePath)) { countryLanguageFile.WriteLine(CountryLanguageInsertClause); CountryLanguages.Select((countrylanguage, index) => new { countrylanguage, index }).ToList().ForEach(x => countryLanguageFile.WriteLine( x.index == 0 ? FormatCountryLanguageValues(x.countrylanguage) : $"union all {FormatCountryLanguageValues(x.countrylanguage)}")); } using (var stateFile = new StreamWriter(StateFilePath)) { stateFile.WriteLine(SetIdentityInsert(nameof(State), true)); stateFile.WriteLine(StateInsertClause); States.ForEach(state => stateFile.WriteLine(state.Id == 1 ? FormatStateValues(state) : $"union all {FormatStateValues(state)}")); stateFile.WriteLine(SetIdentityInsert(nameof(State), false)); } using (var provinceFile = new StreamWriter(ProvinceFilePath)) { provinceFile.WriteLine(SetIdentityInsert(nameof(Province), true)); provinceFile.WriteLine(ProvinceInsertClause); Provinces.ForEach(province => provinceFile.WriteLine(province.Id == 1 ? FormatProvinceValues(province) : $"union all {FormatProvinceValues(province)}")); provinceFile.WriteLine(SetIdentityInsert(nameof(Province), false)); } using (var communityFile = new StreamWriter(CommunityFilePath)) { communityFile.WriteLine(SetIdentityInsert(nameof(Community), true)); communityFile.WriteLine(CommunityInsertClause); Communities.ForEach(community => communityFile.WriteLine(community.Id == 1 ? FormatCommunityValues(community) : $"union all {FormatCommunityValues(community)}")); communityFile.WriteLine(SetIdentityInsert(nameof(Community), false)); } using (var placeFile = new StreamWriter(PlaceFilePath)) { placeFile.WriteLine(SetIdentityInsert(nameof(Place), true)); placeFile.WriteLine(PlaceInsertClause); Places.ForEach(place => placeFile.WriteLine(place.Id == 1 ? FormatPlaceValues(place) : $"union all {FormatPlaceValues(place)}")); placeFile.WriteLine(SetIdentityInsert(nameof(Place), false)); } }