Wednesday, April 6, 2011

linq strange error with null

i have function

public List<Menu> List(int? parentId)
        {          
            return (from i in _dataContext.Menu where i.Menu2.Id == parentId select i).ToList();

        }

if i pass in function parameter null (like List(null)) it search nothing, but if i put null in query like this

return (from i in _dataContext.Menu where i.Menu2.Id == null select i).ToList(); it finds records

what the problem?

From stackoverflow
  • Confirm in the debugger that you are actually passing in null and not 0.

0 comments:

Post a Comment