我有两张桌子:人,地址。 我想:
select Person objects where the person.adress_Id = adress.id and adress.city = "new york".
问题是我FK
和Person
之间没有Adress
,现在我无法添加它。
可以在哪里这样做吗?
感谢。
答案 0 :(得分:0)
您可以在linq中使用join:
from person in dbContext.Persons
join address in dbContext.Addresses on person.address_id equals address.id
where address.city == "new york"
select new
{
person.name,
address.city,
//others...
}
答案 1 :(得分:0)
是的,你可以使用LINQ join
来做到这一点List<Person> persons = (from p in db.Persons
join a in db.Address
on p.adress_Id = a.adress.id
select p).ToList();