title: Using Ternary Operator within Lambda Expression
body: <p>Here is my code:</p>
  
  <pre><code>var now = DateTime.Now;
  var firstOfMonth = new DateTime(now.Year, now.Month, 1, 0, 0, 1);
  
  var objectsAfterFirstOfThisMonth= _context.DataObjects
      .Where(x =&gt; x.dateClosed == null ? x.dateClosed : x.dateCreated &gt; firstOfMonth);
  </code></pre>
  
  <p>I get the following compile error:</p>
  
  <blockquote>
    <p>There is no implicit conversion between 'System.Nullable' and 'bool'</p>
  </blockquote>
  
  <p>I don't understand the lambda syntax enough to understand this error.</p>
  
  <p>If I am unable to use this ternary syntax, then I will be required to get the full list of DataObjects from database, then iterate through this list, creating the filtered list (those objects with dates later than the first of current month) as I go.</p>
  
  <p>My goal in a nutshell is this: I want to get all objects that occured after the first of this month. dateCreated field is never null. dateClosed is sometimes null. dateClosed is more accurate and I want to compare on that date as much as possible, but need to fall back on dateCreated in case dateClosed is null.</p>
  
  <p>Please let me know if I need to provide more information.</p>
  
  <p>Thanks in advance!</p>