Deletion code using LINQ

We use the following code to delete from the database using LINQ:-

		
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq;

public partial class Insert_LINQ_To_SQL : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //create the object of data context class and pass the connection string
        DataContext dc = new DataContext("Data Source=ISHA-PC;Initial Catalog=TechAltum;Integrated Security=True");

        //create object of class which mapped the table in database
        Class1 cal_data;
       

        //set the where clause for delete the data
        cal_data = dc.GetTable<Class1>().Single(res => res.id == Convert.ToInt32(TextBox1.Text));

        //add object to the delete method
        dc.GetTable<Class1>().DeleteOnSubmit(cal_data);
        dc.SubmitChanges();
      
      
    }
}

		
		

Email Address

For any query you can send mail at info@techaltum.com
Thanks