Пример #1
0
 public async static Task DeleteAssetCategory(AssetCategory itemPara)
 {
     using (var db = new SalesContext())
     {
         db.Entry(itemPara).State = EntityState.Unchanged;   //NOT DELETE - IMPORTANT
         AssetCategories.Remove(itemPara);
         db.Entry(itemPara).State = EntityState.Deleted;     // must be executed after deleted it in AssetCategories
         await UpdateDatabase(db);
     }
 }
Пример #2
0
 public async static Task DeleteManyAssetCategories(IList itemParas)
 {
     using (var db = new SalesContext())
     {
         List <AssetCategory> list = new List <AssetCategory>();
         foreach (object item in itemParas)
         {
             list.Add((AssetCategory)item);
         }
         foreach (AssetCategory item in list)
         {
             db.Entry(item).State = EntityState.Unchanged;
             AssetCategories.Remove(item);
             db.Entry(item).State = EntityState.Deleted;
         }
         await UpdateDatabase(db);
     }
 }