I saw posts like below which are really hard for me to understand. So I am re-posting it. Sorry if someone feels it\'s duplicate. I have just simple requirements
C# Join
Perform join on those two methods returning values by Lambda style Linq syntax:
var query = GetNames().Join(GetMailingAddress(),
n => n.Id,
e => e.Id,
(n, e) => new { n.Id,n.Name,e.Email});
foreach (var item in query)
{
Console.WriteLine(item.Id + "-" + item.Name +"-"+ item.Email);
}
Perform join on those two methods returning values by Sql-style Linq syntax:
var query = from n in GetNames()
join e in GetMailingAddress()
on n.Id equals e.Id
select new {n.Id,n.Name,e.Email };
foreach (var item in query)
{
Console.WriteLine(item.Id + "-" + item.Name +"-"+ item.Email);
}
Note:Where GetName() and GetMailingAddress() method returns list of result set.