I am having difficulty understanding this problem:
Here is the T-SQL query I need to implement using LINQ to Entities
select r.ReviewID, b.BusinessID, b.Name as BusinessName ,r.Description
from gb_business.Review r
inner join gb_business.Business b on r.BusinessID = b.BusinessID
inner join gb_listing.RegionalService rs on b.BusinessID = rs.BusinessID
where r.ReviewStatusID=1 and rs.TypeID=1 and rs.IsMain=1
In VS2010 it looks like this (without the where clause)
var res1 = (from r in context.Review
join b in context.Business on r.BusinessID equals b.BusinessID
join rs in context.RegionalService on b.BusinessID equals rs.Business.BusinessID
select r).ToList();
This expression compiles well but at run time there is an exception: The specified type member 'BusinessID' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
I am wondering why BusinessID is a problem. Thank you.
BusinessID
? Also, your second join links through an association. (rs.Business.BusinessID
instead ofrs.BusinessID
as I would have expected.)rs.Business.BusinessID
? it should bers.BusinessID
. You cannot joinRegionalService
entity on entity member of another entity (Business.BusinessID
).