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.
Best Answer
The answer to your question is given there : Question : Can I create a linq to entity query on non entity member fields
When using thoses LinQ to entity queries, you can only use 'entity members' that are properties that are defined inside your data table.
Since your queries are wrapped ("translated") into SQL commands, you must use properties that are defined in your Data Model.
In your example, I would strongly suggest you to ensure that 'BusinessID' matches to an existing data column.