Wednesday, December 14

Join with three tables using Linq Query

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

public partial class Default3 : System.Web.UI.Page
{
    public string connection = ConfigurationManager.ConnectionStrings["DemoConnectionString"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        DataClassesDataContext dc = new DataClassesDataContext(connection);
        var x=from m in dc.mytables join y in dc.yourtables on m.pid equals y.pid into grouping from y in dc.yourtables join o in dc.ourtables on y.pid equals o.pid  select new{m.name, y.pid,y.money,o.first,o.second };
        GridView1.DataSource = x;
        GridView1.DataBind();
    }
}

No comments:

Post a Comment

Please don't spam, spam comments is not allowed here.

.

ShibashishMnty
shibashish mohanty