private void populateDatabase() { writeMessage("Populating Database"); using (DataClasses1DataContext dc = new DataClasses1DataContext()) { dc.ExecuteCommand("TRUNCATE TABLE invoicelines"); foreach (var line in callList) { invoiceline objref = new invoiceline(); objref.firstname = line.firstname; objref.lastname = line.lastname; objref.ref_number = line.asdReference; objref.hoursthisperiod = 0; dc.invoicelines.InsertOnSubmit(objref); dc.SubmitChanges(); } // remove duplicate entries var duplicates = (from r in dc.invoicelines group r by new { r.firstname, r.lastname } into results select results.Skip(1) ).SelectMany(a => a); dc.invoicelines.DeleteAllOnSubmit(duplicates); dc.SubmitChanges(); } }
partial void Updateinvoiceline(invoiceline instance);
partial void Deleteinvoiceline(invoiceline instance);
partial void Insertinvoiceline(invoiceline instance);