I have to use Linq to Insert Update Delete in C# windowsformAshok Karale13yAsked Oct 17, 2013, 10:03 PM EDT1 answerShareLinkedInXCopy linkSaveI have Registration a form as below:the coding of it in traditional and beginners way of coding i think. So now I have to use Ling to SQL to develop the same.Please help me to do this.Thanks in advance.1 AnswerKnow the answer? Post it. Somebody with the same question will find it here.FMFormer member13y agoPosted Oct 17, 2013, 10:07 PM EDT0Hi Ashok,try this code below// Query for a specific customer. var cust = (from c in db.Customers where c.CustomerID == "ALFKI" select c).First();// Change the name of the contact.cust.ContactName = "New Contact";// Create and add a new Order to the Orders collection.Order ord = new Order { OrderDate = DateTime.Now };cust.Orders.Add(ord);// Delete an existing Order.Order ord0 = cust.Orders[0];// Removing it from the table also removes it from the Customer's list.db.Orders.DeleteOnSubmit(ord0);// Ask the DataContext to save all the changes.db.SubmitChanges();My help your0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign in
I have to use Linq to Insert Update Delete in C# windowsformAshok Karale13yAsked Oct 17, 2013, 10:03 PM EDT1 answerShareLinkedInXCopy linkSaveI have Registration a form as below:the coding of it in traditional and beginners way of coding i think. So now I have to use Ling to SQL to develop the same.Please help me to do this.Thanks in advance.
FMFormer member13y agoPosted Oct 17, 2013, 10:07 PM EDT0Hi Ashok,try this code below// Query for a specific customer. var cust = (from c in db.Customers where c.CustomerID == "ALFKI" select c).First();// Change the name of the contact.cust.ContactName = "New Contact";// Create and add a new Order to the Orders collection.Order ord = new Order { OrderDate = DateTime.Now };cust.Orders.Add(ord);// Delete an existing Order.Order ord0 = cust.Orders[0];// Removing it from the table also removes it from the Customer's list.db.Orders.DeleteOnSubmit(ord0);// Ask the DataContext to save all the changes.db.SubmitChanges();My help your0
Former memberPosted Oct 17, 2013, 10:07 PM EDT
try this code below
My help your