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