/* * Add a cow to local database */ public static void AddCow(Cow cowJSON) { using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString)) { try { cowDB cow = new cowDB(); cow.nv = cowJSON.nv; cow.nombre = cowJSON.nombre; cow.dias_lac = cowJSON.dias_lac; cow.hato = cowJSON.hato; cow.loc = cowJSON.loc; cow.lts_dia = cowJSON.lts_dia; cow.partos = cowJSON.partos; cow.ultimo_parto = cowJSON.ultimo_parto; cow.primer_servicio = cowJSON.primer_servicio; System.Diagnostics.Debug.WriteLine("agregando"); context.cows.InsertOnSubmit(cow); context.SubmitChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } } }
public static void deleteAllCows() { using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString)) { IQueryable<cowDB> entityQuery = from c in context.cows select c; IList<cowDB> entityToDelete = entityQuery.ToList(); context.cows.DeleteAllOnSubmit(entityToDelete); context.SubmitChanges(); } }