开发者

LINQ Contains Null

I've a LINQ contains empty/null value that works on my local machine but not on my production box. This would be a where cla开发者_如何学Gouse.

Does this make any sense?


From the limited info you provided, my first guess is that the objects or entities your Linq statement is working against have some null values that you're not expecting when performing an operation within the WHERE lambda. Your test box has everything populated, but the production environment does not. For instance, referencing MyObject.ChildObject.ChildProperty when MyObject has no child will generate a NullReferenceException. If MyObject isn't required to have a ChildObject in some or all circumstances, you must perform simple null checks to handle this case safely.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜