i have 4 list that I need to join together
public class Person
{
public int personid { get; set; }
public string fname { get; set; }
public string lname { get; set; }
}
public class Department
{
int depid { get; set; }
string departmentname { get; set; }
}
public class Group
{
public int groupid { get; set; }
public int depid { get; set; }
public string groupname { get; set; }
}
public class UploadFile
{
public int fileid { get; set; }
public int personid { get; set; }
public int groupid{ get; set; }
public string filename { get; set; }
}
List
List
List
List
I need an output like:
fileid fname lname filename path
1 Jon ... ... departmentname+">"+groupname
thanks!

VulpesPosted Apr 12, 2012, 5:26 AM
Ajay PatelPosted May 11, 2012, 8:23 AM
http://ajaypatelfromsanthal.blogspot.in/2012/05/joins-in-linq.html
SenthilkumarPosted Apr 12, 2012, 4:48 AM
You need to join by the key fields.
join D in Departmentlist on D.depid equals G.depid
join G in Grouplist on G.groupid equals U.groupid
join U in Filelist U.personid equals P.personid
select new { U.fileid,P.fname,P.lname, path = U.filename + ">" + U.Path };
The query will have the joined table results.
Now you can iterate the results.
// Display joined groups.
foreach (var group in query)
{
Console.WriteLine(group.fileid+" "+ group.fname+" "+group.lname+" "+group.path);
}
Hope this will help you.