I occured a strange problem. I have that method
public static void ProcessCategories(int? myID)
{
var tmpList = Adapter.Category.Where(x => x.IdParentCategory == myID).ToList();
}
when myID == null
开发者_如何学Go (the parameter), the tmpList doesn't contain any elements, but if I type
x.IdParentCategory == null
then some items are returned. Why ?
Try this:
public static void ProcessCategories(int? myID)
{
var tmpList = Adapter.Category.Where(x => x.IdParentCategory == myID || (myID == null && x.IdParentCategory == null)).ToList();
}
精彩评论