コード例 #1
0
 /// <summary>
 /// Create a new Country object.
 /// </summary>
 /// <param name="countryID">Initial value of the CountryID property.</param>
 /// <param name="countryName">Initial value of the CountryName property.</param>
 public static Country CreateCountry(global::System.Int32 countryID, global::System.String countryName)
 {
     Country country = new Country();
     country.CountryID = countryID;
     country.CountryName = countryName;
     return country;
 }
コード例 #2
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);
 }
コード例 #3
0
        private Int32 AddCountry(string countryName)
        {
            var countries = entities.Countries;
            foreach (var i in countries)
            {
                if(String.Equals(i.CountryName.ToLower(),countryName.Trim().ToLower()))
                {
                    return i.CountryID;
                }
            }
            Country newCountry = new Country();
            newCountry.CountryName = countryName.Trim();

            entities.Countries.AddObject(newCountry);
            entities.SaveChanges();
            return newCountry.CountryID;
        }