public static bool ClearRecords() { bool returnVal = true; try { RootObject[] tmp = null; using (SigimeraDataContext context = new SigimeraDataContext(Shared.CONNECTION_STRING)) { do { //Delete in chunks of 10 records each tmp = context.CrisisItems.Take(10).ToArray(); if (tmp.Length > 0) { context.CrisisItems.DeleteAllOnSubmit(tmp); context.SubmitChanges(); } } while (tmp.Length > 0); } } catch (Exception ex) { returnVal = false; } return returnVal; }
public static void AddCrisis(RootObject earthquakeEvent) { using (SigimeraDataContext context = new SigimeraDataContext(Shared.CONNECTION_STRING)) { context.CrisisItems.InsertOnSubmit(earthquakeEvent); // save changes to the database context.SubmitChanges(); } }
public static void DeleteMessage(string id) { using (SigimeraDataContext context = new SigimeraDataContext(Shared.CONNECTION_STRING)) { IQueryable<RootObject> messageQuery = from c in context.CrisisItems where c._id == id select c; RootObject earthquakeItemToDelete = messageQuery.FirstOrDefault(); context.CrisisItems.DeleteOnSubmit(earthquakeItemToDelete); // save changes to the database context.SubmitChanges(); } }