コード例 #1
0
 public Country CreateCountry(Country country)
 {
     using (var db = new DataAccess())
     {
         db.CreateStoredProcCommand("dbo.CreateCountry");
         db.AddInputParameter("@Name", DbType.String, country.Name);
         db.AddInputParameter("@FullName", DbType.String, country.FullName);
         db.AddInputParameter("@Latitude", DbType.Double, country.Latitude);
         db.AddInputParameter("@Longitude", DbType.Double, country.Longitude);
         db.AddOutputParameter("@CountryId", DbType.Int32);
         try
         {
             db.ExecuteNonQuery();
             country.CountryId = db.GetParameterValue<int>("@CountryId");
         }
         catch (Exception ex)
         {
             Logger.Error("Error while creating country.", ex);
             throw;
         }
     }
     return country;
 }
コード例 #2
0
 public bool TryGetCountry(string country, out Country match)
 {
     using (var db = new DataAccess())
     {
         db.CreateStoredProcCommand("dbo.TryGetCountry");
         db.AddInputParameter("@Country", DbType.String, country);
         db.AddReturnParameter();
         try
         {
             db.ReadInto(match = new Country());
             return Convert.ToBoolean(db.GetReturnValue());
         }
         catch (Exception ex)
         {
             Logger.Error("Error while getting country.", ex);
         }
     }
     match = default(Country);
     return false;
 }