Comparison of user class objects is not supported in Linq to entities
2008-05-10 09:12
549 查看
The linq expression is:
var query = from p in _db.LogProjects
where p.Well == well
select p;
( Well is a user class )
An exception will be thrown:
Unable to create a constant value of type 'Closure type'. Only primitive types (for instance Int32, String and Guid) are supported in this context.
So, you can change the linq expression to:
var query = from p in _db.LogProjects
where p.Well.WellID == well.WellID
select p;
reference:
ADO.NET Entity Framework Comparison Frustration
Entity Framework Comparison Frustration: Explained
var query = from p in _db.LogProjects
where p.Well == well
select p;
( Well is a user class )
An exception will be thrown:
Unable to create a constant value of type 'Closure type'. Only primitive types (for instance Int32, String and Guid) are supported in this context.
So, you can change the linq expression to:
var query = from p in _db.LogProjects
where p.Well.WellID == well.WellID
select p;
reference:
ADO.NET Entity Framework Comparison Frustration
Entity Framework Comparison Frustration: Explained
相关文章推荐
- The specified type member 'IsLock' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
- The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
- UserWarning: The installed version of numexpr 2.4 is not supported in pandas and will be not be used
- -fembed-bitcode is not supported on versions of iOS prior to 6.0
- Your project is not referencing the ".NETPortable,Version=v4.5,Profile=Profile259" framework. Add a reference to ".NETPortable,Version=v4.5,Profile=Profile259" in the "frameworks" section of your proj
- IDEA 编译错误:java: try-with-resources is not supported in -source 1.6 (use -source 7 or higher to enable try-with-resources)
- 记一次Maven 打包multi-catch statement is not supported in -source 1.5 [ERROR] (use -source 7 or higher to
- 【openstack报错】【因更新包而致】IncompatibleObjectVersion: Version 1.9 of Instance is not supported
- mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
- -fembed-bitcode is not supported on versions of iOS prior to 6.0 问题修复
- Maven错误 diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)问题解决
- xcode 7 运行项目报错 -fembed-bitcode is not supported on versions of iOS prior to 6.0
- The Excel Connection Manager is not supported in the 64-bit version of SSIS, as no OLE DB provider i
- -fembed-bitcode is not supported on versions of iOS prior to 6.0问题
- How to solve 'object of abstract class type "newFoo" is not allowed'?
- -fembed-bitcode is not supported on versions of iOS prior to 6.0
- System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is not valid due to the current state of the obj
- 本地提交SVN报错 提交文件 is not known to exist in the repository and is not part of the commit, yet its child
- mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
- 报错:System.NotSupportedException: LINQ to Entities does not recognize the method