I have two tables A & B. I can fire Linq queries & get required data for individual tables. As i know what each of the tables will return as shown in example. But,
The value you generate is called Anonymous Type and you can return it unless you return object like:
private object GetJoinAAndB()
{
var query = from a in objA
join b in objB
on a.ID equals b.AID
select new { a.ID, a.Name, b.Address };
return query.ToList();
}
There are two good solutions:
1. is to generate a class to match the output and generate it like Kobi solution
2. if you are using .net 4 you can return a dynamic type like
private dynamic GetJoinAAndB()
{
var query = from a in objA
join b in objB
on a.ID equals b.AID
select new { a.ID, a.Name, b.Address };
return query.ToList();
}
then you can use it later. You can search the internet about the advantage of using dynamic keyword.