category.ParentCategoryId = @parentCategoryId
or
category.ParentCategoryId = null and this sql didn't return result, because expect category.ParentCategoryId is null.
Then I test another way to delive null value
if (parentCategoryId == null)
{
var query = from
category in this.productsHelpDataContext.Categories
orderby
category.Order ascending
where
category.ParentCategoryId == null
select category;
return query.Select(category => category);
}
else
{
var query = from
category in this.productsHelpDataContext.Categories
orderby
category.Order ascending
where
category.ParentCategoryId == parentCategoryId
select category;
return query.Select(category => category);
}
In other word LINQ to SQL strict follow sql script convention.