Reputation: 7311
I have an IQueryable
object like this
var persons = from m in db.Persons
select m;
The returned fields will be: name: String
, family: String
, cityID: Int
in it. I have another IQueryable
object that get cityID: Int
and CityName: String
from another table like one here:
var citys = from x in db.CitysInfo
select x;
Now I want an IQueryable
object that have name: String
, family: String
, CityName: String
. How can I do that?
Upvotes: 3
Views: 1833
Reputation: 160912
You could use a join and project to an anonymous class:
var results = from p in db.Persons
join c in db.CitysInfo on p.cityID equals c.cityId
select new
{
name = p.name,
family = p.family,
CityName = c.CityName,
}
Upvotes: 4