Wednesday, January 19, 2011

Use Linq In Global.asax in asp.net


<%@ Application Language="C#" %>
<%@ Import Namespace="System.Xml.Linq" %>
<%@ Import Namespace="System.Linq" %>
<script runat="server">
    void Session_End(object sender, EventArgs e)
    {
        MyLinqDataClassesDataContext mylinq = new MyLinqDataClassesDataContext(); 
        if (Session["uname"] != null)
        {
        var deleteuser = from p in mylinq.userCredentials
                         where p.uname_db.Contains(Session["uname"].ToString())
                         select p;           
            mylinq.userCredentials.DeleteAllOnSubmit(deleteuser);
            mylinq.SubmitChanges();
        }
    }
</script>

No comments:

Post a Comment