我在使用以下 linq 查询时遇到问题。
public class Address
{
public int addressID { get; set; }
public string address { get; set; }
}
public class AdvanceClient
{
public int ClientID { get; set; }
public string Name { get; set; }
public string Mobile { get; set; }
public IEnumerable<Address> Addresses { get; set; }
}
在下面的 linq 查询中,我想将 IEnumerable 地址列表分配给 Addresses 属性。我在 tblAdvanceClient 和 tblAddress 表之间存在一对多的关系。
IEnumerable<AdvanceClient> addcli = from tbcli in dc.tblAdvanceClients
join tbadd in dc.tblAddresses
on tbcli.AddressID equals tbadd.AddressID
select new AdvanceClient
{
ClientID = tbcli.ClientID,
Company = tbcli.Company,
Fax = tbcli.Fax,
Mobile = tbcli.Mobile,
Name = tbcli.Mobile,
Telephone = tbcli.Telephone,
Addresses = new Address { } // Here i need to get the list of address to each client
};