Exemple #1
0
        private void ImportCountriesWithAliases()
        {
            using ( var trans = new TransactionScope() )
            {
                using ( var tom = Engine.ServiceProvider.CreateEntityRepository() )
                {
                    foreach ( var record in CountryAliasRecords )
                    {
                        var lcid = record.Item1;
                        var alias = record.Item2;

                        var country = tom.Countries.FirstOrDefault( c => c.LCID == lcid );
                        if ( country == null )
                        {
                            country = new Country( lcid );

                            tom.Countries.AddObject( country );
                        }

                        if ( !tom.CountryAliases.Any( a => a.Name == alias ) )
                        {
                            var countryAlias = new CountryAlias( country, alias );

                            tom.CountryAliases.AddObject( countryAlias );
                        }
                    }

                    tom.SaveChanges();
                }

                trans.Complete();
            }
        }
Exemple #2
0
 /// <summary>
 /// Create a new Country object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="lCID">Initial value of the LCID property.</param>
 public static Country CreateCountry(global::System.Int64 id, global::System.Int64 lCID)
 {
     Country country = new Country();
     country.Id = id;
     country.LCID = lCID;
     return country;
 }
Exemple #3
0
 public CountryAlias( Country country, string name )
 {
     Country = country;
     Name = name;
 }
Exemple #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Countries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCountries(Country country)
 {
     base.AddObject("Countries", country);
 }