Jam*_*mes 5 c# linq linq-to-entities entity-framework
以下按预期工作(LINQ to Entities):
var topics = (from t in ctx.Topics where t.SubjectId == subjectId && t.ParentId == null select new { t.Title, t.Id }).ToList();
Run Code Online (Sandbox Code Playgroud)
但是,以下内容不返回:
int? parent = null;
var topics = (from t in ctx.Topics where t.SubjectId == subjectId && t.ParentId == parent select new { t.Title, t.Id }).ToList();
Run Code Online (Sandbox Code Playgroud)
Topic.ParentId是一个可以为null的int.这很容易解决,但这让我很困惑.谁能摆脱任何光明?
您绝对不是第一个观察到这种……有趣的……行为的人。
简而言之,处理 null 的不同表达方式是很困难的。
| 归档时间: |
|
| 查看次数: |
846 次 |
| 最近记录: |