我有 4 张桌子:
地址 - AddressID、城市、地址、邮政编码
OBAddress - OBID、AddressID
OB-OBID
状态 - StateID,StateAbbreviation
如何加入多对多关系的三个表?我试过:
var recordsPhysicalAddress = ( from a in db.Addresses
join oba in db.obAddresses on a.AddressID equals oba.AddressID
join ob in db.obAddresses on oba.obID equals passedinID
join s in db.States on a.StateID equals s.StateID
where oba.obID == ob.obID
&& a.AddressTypeID == '5' //5 is records physical address
select new
{
a.Address1,
a.City,
a.StateID,
s.StateAbbreviation,
a.ZipCode
}).FirstOrDefault();