我正在寻找Msql查询的对应方法:
SELECT per.*,add.addressDescription FROM Persons per
JOIN Address add ON per.AddressId = add.AddressId
我有以下查询:
var query = persons.JOIN(address,per = person.addressId,add = addressId
(per,add) =>
new Persons{
addressDescription = add.addressDescription,
PersonId = per.PersonId,
PersonFirstName = per.PersonFirstName
PersonLastName = per.PersonLastName})
有没有一种方法可以在不单独赋值Persons
的其他属性的情况下填充Persons.addressDescription
?假设Persons
还有10个以上的属性。
我想避免使用像这样的循环:
foreach(Person person in PersonList)
{
foreach(Address address in AddressList)
{
if(person.addressId == address.addressId){
person.addressDescription = address.addressDescription
}
}
}