Пример #1
0
 public void DeleteFromDB()
 {
     using (var _db = new DataClasses1DataContext())
     {
         TItem _item = new TItem() { id = this.id };
         _db.TItems.Attach(_item);
         _db.TItems.DeleteOnSubmit(_item);
         _db.SubmitChanges();
     }
 }
Пример #2
0
 public void SaveToDB()
 {
     using (var _db = new DataClasses1DataContext())
     {
         try
         {
         var _item = _db.TItems.Single(x => x.id == this.id);
             _item.name = this.name;
         }
         catch
         {
             var _item = new TItem();
             _item.name = this.name;
             _db.TItems.InsertOnSubmit(_item);
         }
         _db.SubmitChanges();
     }
 }
Пример #3
0
 //static public void DelFromDB(Guid _id)
 //{
 //    using (var _db = new DataClasses1DataContext())
 //    {
 //        TItem _item = _db.TItems.SingleOrDefault(x => x.id == _id);
 //        _db.TItems.DeleteOnSubmit(_item);
 //        _db.SubmitChanges();
 //    }
 //}
 public static void UpdGroups(Guid _item_id, Guid _group_id, bool _action)
 {
     using (var _db = new DataClasses1DataContext())
     {
         if (_action)
         {
             var _grp = new RItemsGroup();
             _grp.Item_id = _item_id;
             _grp.Group_id = _group_id;
             _db.RItemsGroups.InsertOnSubmit(_grp);
         }else
         {
             var _item = _db.RItemsGroups.Single(x => ((x.Item_id == _item_id) && (x.Group_id == _group_id)));
             _db.RItemsGroups.DeleteOnSubmit(_item);
         }
         _db.SubmitChanges();
     }
 }