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?
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,
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.