0
我发生了一个奇怪的问题。我有一个方法LINQ2SQL基于参数返回项目的问题
public static void ProcessCategories(int? myID)
{
var tmpList = Adapter.Category.Where(x => x.IdParentCategory == myID).ToList();
}
时myID == null
(参数),该tmpList不包含任何元素,但如果我键入
x.IdParentCategory == null
然后返回一些项目。为什么?
我想这是因为在SQL中,你必须比较像这样的空值:其中列为空。但非空值与= – Thorgeir 2010-11-16 15:59:31
代码生成一个错误'委托'System.Func'不需要1个参数' –
Tony
2010-11-16 16:06:57
嗯..我不知道这是为什么。但这里是一个有相同问题的人http://stackoverflow.com/questions/586097/compare-nullable-types-in-linq-to-sql – Thorgeir 2010-11-17 09:03:52