开发者

LINQ Contains Null

开发者 https://www.devze.com 2023-02-13 00:33 出处:网络
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.

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

精彩评论

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