下按预期工作(LINQ到实体):可空的int未按预期在LINQ(C#)
var topics = (from t in ctx.Topics where t.SubjectId == subjectId && t.ParentId == null select new { t.Title, t.Id }).ToList();
但是,下列不返回任何内容:
int? parent = null;
var topics = (from t in ctx.Topics where t.SubjectId == subjectId && t.ParentId == parent select new { t.Title, t.Id }).ToList();
Topic.ParentId是可空的int。这很容易解决,但这让我感到困惑。任何人都可以摆脱光线吗?
Jon Skeet来救援! ;-) – 2011-04-12 18:44:08
同样的问题在这里:http://stackoverflow.com/questions/682429/how-can-i-query-for-null-values-in-entity-framework/4262617#4262617 – Slauma 2011-04-12 18:58:07