示例#1
0
 internal static attraction Create(attraction i)
 {
     using (var db = new DataClassesDataContext()) {
         db.attractions.InsertOnSubmit(i);
         db.SubmitChanges();
         return(i);
     }
 }
示例#2
0
 internal static attraction Update(attraction i)
 {
     using (var db = new DataClassesDataContext()) {
         var old = db.attractions.SingleOrDefault(it => it.items_id == i.items_id);
         if (old != null)
         {
             foreach (PropertyInfo property in typeof(attraction).GetProperties())
             {
                 if (property.Name == "item")
                 {
                     break;
                 }
                 property.SetValue(old, property.GetValue(i, null), null);
             }
         }
         else
         {
             db.attractions.InsertOnSubmit(i);
         }
         db.SubmitChanges();
         return(i);
     }
 }