Reputation: 7543
The following works as expected (LINQ to Entities):
var topics = (from t in ctx.Topics where t.SubjectId == subjectId && t.ParentId == null select new { t.Title, t.Id }).ToList();
However, the following returns nothing:
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 is a nullable int. It's easy to work around, but this puzzles me. Can anyone shed any light?
Upvotes: 5
Views: 906
Reputation: 3498
You are definately not the first person to observe this... interesting... behavior.
In short, it's difficult to handle different ways of expressing null.
Upvotes: 4