.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> LINQ >> Post New QuestionBookmark and Share Subscribe to Forum

Linq Multiple Select

Posted By: Sasi Prabhu     Posted Date: April 03, 2012    Points:5   Category :LINQ
Hi friends,
i need the Linq Query to select datas from 3 Tables.

I acheived in c# Code. But i need to develop in LINQ Query.

foreach (DataRow drChapters in dtChapter.Rows)
{
DataRow dr = dtPlanInfo.NewRow();
foreach (DataRow drMileStone in dtMileStones.Rows)
{
dr["Chapter"] = drChapters["Chapter"].ToString();
DataRow[] drStages = dtStages.Select("Chapter='" + drChapters["Chapter"].ToString() + "' and MilestoneDesc='" + drMileStone["MilestoneDesc"] + "'");
foreach (DataRow drs in drStages)
{
dr[drMileStone["MilestoneDesc"].ToString() + "PlanDate"] = drs["PlanDate"];
dr[drMileStone["MilestoneDesc"].ToString() + "ActualDate"] = drs["ActualDate"];
dr[drMileStone["MilestoneDesc"].ToString() + "Remarks"] = drs["Remarks"].ToString();
dr[drMileStone["MilestoneDesc"].ToString() + "RevisedCount"] = drs["RevisedCount"];
dr[drMileStone["MilestoneDesc"].ToString() + "LastTimeRevised"] = drs["LastRevisedPlanDate"];
}
}
dtPlanInfo.Rows.Add(dr);
}

The Tables involved are
Chapter
Ch1
ch2

MileStoneDesc
M1
M2
M3

StageId , PlanDate , ActualDate , Remarks , Chapter , MilestoneDesc , revisedCount , LastTimeRevised
1 , 12/9/2012 , 15/12/2012 , test , Ch1 , M1 , ,
2 , 3/2/2013 , 5/6/2013 , test2 , ch2 , M2 , ,


I need the Result as

Chapter , M1Plan , M1Actual , M1Remark , M1RevisedCount , M1LastRevised , M2Plan , M2Actual , M2Remark , M2RevisedCount , M2LastRevised
ch1 , 12/9/2012 , 15/12/2012 , test , , , , , , ,
ch2 , , , , , , 3/2/2013 , 5/6/2013 , test2 , ,

Provide me the Linq Query to get this result.


Responses
Author: Narayanan             
Posted Date: January 16, 2013     Points: 20   


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend