Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 具有实体框架条件字符串比较的SQL Server Compact 4.0_C#_Entity Framework_Sql Server Ce - Fatal编程技术网

C# 具有实体框架条件字符串比较的SQL Server Compact 4.0

C# 具有实体框架条件字符串比较的SQL Server Compact 4.0,c#,entity-framework,sql-server-ce,C#,Entity Framework,Sql Server Ce,如果null值存储在变量中,实体框架似乎无法将该值与null进行比较: 因此,我正在做一些类似的事情,正如So的其他用户所建议的那样: string description = null; var transactions = from t in entities.Transactions where description == null ? t.Description == null : t.Description == description

如果null值存储在变量中,实体框架似乎无法将该值与null进行比较:

因此,我正在做一些类似的事情,正如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
你知道我为什么会这样,以及我如何克服它吗?

是的,显然

不过,您可以在客户端执行此操作:

var transactions = description == null ?
                    entities.Transactions.Where(t.Description == null)
                    : entities.Transactions.Where(t.Description == description);
…我怀疑在这种情况下不会生成任何
ISNULL