下面是我的linq查询:
var test = from m in db.Members where m.UserId == null select m.Id;
test.ToList();UserId是members表上的一个可以为空的Guid字段,它对应于ASP.NET成员资格表aspnet_member。我无法通过subsonic生成查询,该查询将选择userid为null的位置,只有不为null的位置。
以下是我的预期输出:
SELECT Id FROM Member WHERE UserId IS NULL以下是我的实际输出:
SELECT Id FROM Member WHERE UserId IS **NOT** NULL有什么想法吗?我正在调试过程中,但可能是其他人遇到了这个问题。
发布于 2009-09-17 18:31:39
事实证明,在VisitBinary方法中没有实现ExpressionType.Equals。最近有一个补丁可以在这里找到:
[http://github.com/subsonic/SubSonic-3.0/blob/master/SubSonic.Core/Linq/Structure/TSqlFormatter.cs][1]
旧的代码是:
case ExpressionType.Equal:
case ExpressionType.NotEqual:
if (right.NodeType == ExpressionType.Constant)
{
ConstantExpression ce = (ConstantExpression)right;
if (ce.Value == null)
{
this.Visit(left);
sb.Append(" IS NOT NULL");
break;
}
}
else if (left.NodeType == ExpressionType.Constant)
{
ConstantExpression ce = (ConstantExpression)left;
if (ce.Value == null)
{
this.Visit(right);
sb.Append(" IS NOT NULL");
break;
}
}
goto case ExpressionType.LessThan;已为Equal添加实现。除了发出Is NULL而不是is NOT NULL之外,IS与NotEqual几乎相同。
https://stackoverflow.com/questions/1440263
复制相似问题