Clean way to check for Null in Lambda Expressions

c#, lambda

Solution

var result = Store.FirstOrDefault(x => x.Products.Coupon != null && x.Products.Coupon.Any() && x.Products.Coupon[0] == 100);

Problem

I have seen a lot of questions on this but was not able to find a clean solution: I have the following lambda expression: ``` var result = Store.FirstOrDefault(x.Products.Coupon[0] == 100); ``` I would like to check for null for the Coupon collection to check to see if its not null and then compare the first coupon with the value 100. What would be a clean way to check for NULL for Coupon in the lambda? I do not want to use an extension method to check for null. I would like to do the check inline.

Original source