次のlinq to sqlクエリを使用して結果を取得しようとしています。ただし、parentCategoryId が null として渡された場合は機能しません
public static IEnumerable<Category> GetChildren(this Table<Category> source, int? parentCategoryId)
{
var categories = from c in source where c.ParenCategoryId == parentCategoryId select c;
return categories;
}
ただし、parentCategoryId の代わりに null を直接使用すると、次のように動作します
public static IEnumerable<Category> GetChildren(this Table<Category> source, int? parentCategoryId)
{
var categories = from c in source where c.ParenCategoryId == null select c;
return categories;
}