Пример #1
0
 /// <summary>
 /// update single entity of a table
 /// </summary>
 /// <typeparam name="BookingDJDataContext"></typeparam>
 /// <param name="obj"></param>
 public static void Update <T>(OMSDataContext Database, T obj) where T : class
 {
     //finally submit an add/updated entity object to database
     try
     {
         Database.SubmitChanges(ConflictMode.ContinueOnConflict);
     }
     catch (ChangeConflictException e)
     {
         foreach (ObjectChangeConflict cc in Database.ChangeConflicts)
         {
             //No database values are automerged into current
             cc.Resolve(RefreshMode.KeepCurrentValues);
         }
     }
 }
Пример #2
0
        public static void Delete <T>(OMSDataContext Database, T entity) where T : class, new()
        {
            //var Database = DatabaseHelper.GetBookingDJData();
            //Database.GetTable<T>().Attach(entity);
            Database.GetTable <T>().DeleteOnSubmit(entity);

            try
            {
                Database.SubmitChanges();
            }
            catch (ChangeConflictException e)
            {
                foreach (ObjectChangeConflict cc in Database.ChangeConflicts)
                {
                    //No database values are automerged into current
                    cc.Resolve(RefreshMode.OverwriteCurrentValues);
                }
            }
        }