示例#1
0
 public void DeleteSheet(int?sheetId)
 {
     using (var db = new UranusContext()) {
         var sheet = db.Sheets.Include(s => s.FileDetails)
                     .Include(s => s.SheetsCounties)
                     .SingleOrDefault(s => s.SheetId == sheetId);
         DeleteSheet(db, sheet);
         db.SaveChanges();
     }
 }
示例#2
0
 public void DeleteChain(int?chainId)
 {
     using (var db = new UranusContext()) {
         var chain = db.Chains.Include(c => c.Sheets)
                     .SingleOrDefault(c => c.ChainId == chainId);
         // Removes sheets (children)
         foreach (var sheet in chain.Sheets.ToList())
         {
             DeleteSheet(db, sheet);
         }
         db.Chains.Remove(chain);
         db.SaveChanges();
     }
 }
示例#3
0
    public void DeleteSheet(int?sheetId, UranusContext db)
    {
        var sheet = db.Sheets.Include(s => s.FileDetails)
                    .Include(s => s.SheetsCounties)
                    .SingleOrDefault(s => s.SheetId == sheetId);

        foreach (var fileDetails in sheet.FileDetails.ToList())
        {
            db.FileDetails.Remove(fileDetails);
        }

        foreach (var sheetsCounties in sheet.SheetsCounties.ToList())
        {
            db.SheetsCounties.Remove(sheetsCounties);
        }

        db.Sheets.Remove(sheet);
        db.SaveChanges();
    }