![](/img/trans.png)
[英]SQL Server Compact 4.0 connection string for Entity Framework code first?
[英]SQL Server Compact 4.0 with Entity Framework Conditional String Comparison
如果该null值存储在变量中,似乎Entity Framework无法将其与null进行比较: http : //data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-的建议/建议/ 1015361-其中null变量在cl-ref = title中的处理不正确
因此,我正在按照SO其他用户的建议进行以下操作:
string description = null;
var transactions = from t in entities.Transactions
where description == null ? t.Description == null : t.Description == description
select t;
虽然此技术在处理int时效果很好? 还是double?,SQL Server Compact在使用字符串时会引发EntityCommandExecutionException(如上例所示)。 该异常包含以下详细信息:
InnerException: System.Data.SqlServerCe.SqlCeException
Message=The specified argument value for the function is not valid. [ Argument # = 1,Name of function(if known) = isnull ]
Source=SQL Server Compact ADO.NET Data Provider
知道我为什么要得到它以及如何克服它吗?
是的,显然ISNULL在Compact中很时髦 。
不过,您可以在客户端上执行此操作:
var transactions = description == null ?
entities.Transactions.Where(t.Description == null)
: entities.Transactions.Where(t.Description == description);
...而且我怀疑在这种情况下不会生成ISNULL
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.