I need get all items these have no categories
int? categoryId = null;
var items=db.Items.Where(x=>x.CategoryId==categoryId);
this code generate in where:
where CategoryId=null
instead of
where CategoryId is null
ok, when i write
var items=db.Items.Where(x=>x.CategoryId==null);
in my sql profiler it works:
where CategoryId is null
BUT when i do this HACK it doesn't:
var items=db.Items.Where(x=>x.CategoryId==(categoryId.HasValue ? categoryId : null));
so what's the problem? is there by in L2S?
Update: if categoryId has value it need return something like this:
where CategoryId=1