Here is my code:
var now = DateTime.Now;
var firstOfMonth = new DateTime(now.Year, now.Month, 1, 0, 0, 1);
var objectsAfterFirstOfThisMonth= _context.DataObjects
.Where(x => x.dateClosed == null ? x.dateClosed : x.dateCreated > firstOfMonth);
I get the following compile error:
There is no implicit conversion between 'System.Nullable' and 'bool'
I don't understand the lambda syntax enough to understand this error.
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.
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.
Please let me know if I need to provide more information.
Thanks in advance!