コード例 #1
0
ファイル: RegionSeeder.cs プロジェクト: jonsagara/AddressForm
        private static void SeedRegion(AddressFormDbContext context, Guid id, string countryId, string abbreviation, string name)
        {
            var region = context.Regions.SingleOrDefault(r => r.Id == id);
            if (region != null)
            {
                return;
            }

            region = new Region
            {
                Id = id,
                CountryId = countryId,
                Abbreviation = abbreviation,
                Name = name
            };

            context.Regions.Add(region);
            context.SaveChanges();
        }
コード例 #2
0
        private static void SeedCountry(AddressFormDbContext context, string id, string alpha3Code, string numericCode, string iso3166_2Code, string name)
        {
            var country = context.Countries.SingleOrDefault(c => c.Id == id);
            if (country != null)
            {
                return;
            }

            country = new Country
            {
                Id = id,
                Alpha3Code = alpha3Code,
                NumericCode = numericCode,
                Iso3166_2Code = iso3166_2Code,
                Name = name
            };

            context.Countries.Add(country);
            context.SaveChanges();
        }