LINQ-To-Entity (LINQ to Entities does not support the given type member ".)

c# entity-framework lambda linq-to-entities

Question

I'm having trouble comprehending this issue:

Here is the T-SQL query I must use LINQ to Entities to implement.

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

This is how it appears in VS2010 (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();

Although this expression successfully compiles, LINQ to Entities does not support the required type member "BusinessID" at runtime. The only supported types are initializers, entity members, and entity navigation properties.

Why is BusinessID an issue, I wonder. I'm grateful.

1
1
4/11/2012 5:46:38 PM

Popular Answer

There you will find the response to your inquiry: Can I make a linq to entity query on fields that are not members of an entity?

You can only utilize "entity members," which are attributes that are declared within your data table, when employing those LinQ to entity queries.

You must utilize attributes that are specified in your Data Model since your queries are "translated" into SQL statements.

I highly advise you to check if "BusinessID" corresponds to an existent data field in your case.

4
5/23/2017 10:31:29 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow