Skip to content

I have to use Linq to Insert Update Delete in C# windowsform

Ashok Karale

Ashok Karale

Asked Oct 17, 2013, 10:03 PM EDT1 answer
Share
LinkedInX
I 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 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi 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 your
    0