In my data model I have a listing of jobs. Currently jobs only have two states not invoiced or invoiced. The difference is the invoice date. An open job has null as an invoice date.
In my index view I want to enable an option to view only open jobs. Generally I am not as interested in closed jobs in this view. Whilst all jobs I can view from other views where it is more relevant.
In my SQL table the value as a placeholder inserted by EF is 1/01/0001 12:00 AM. I could alter the data model to allow null here but don't see a point this is good enough for the purpose as I wasn't in business in year 1.
I am struggling to understand how to write the Lambda statement to exclude any entry with a date not equal to this default value.
I have tried:
Which whilst it would be nonsense is pushing an error on ToListAsync.
Which would seem to be close to correct...except this gives me an error telling me I cant have not statements on invoice date.I am lost on this. How can I exclude by dates that aren't 1/1/0001 etc?Thanks
In my index view I want to enable an option to view only open jobs. Generally I am not as interested in closed jobs in this view. Whilst all jobs I can view from other views where it is more relevant.
In my SQL table the value as a placeholder inserted by EF is 1/01/0001 12:00 AM. I could alter the data model to allow null here but don't see a point this is good enough for the purpose as I wasn't in business in year 1.
I am struggling to understand how to write the Lambda statement to exclude any entry with a date not equal to this default value.
I have tried:
C#:
[COLOR=blue]public[/COLOR] [COLOR=blue]async[/COLOR] [COLOR=#2b91af]Task[/COLOR]<[COLOR=#2b91af]IActionResult[/COLOR]> Index()
{
[COLOR=blue]var[/COLOR] EVAContext = _context.Job
.Include(j => j.Site)
.ThenInclude(j => j.WaterBodys)
[COLOR=green]// .ThenInclude(j=>j.WBName)[/COLOR]
.AsNoTracking()
.SingleOrDefaultAsync(j=>j.InvoiceDate==[COLOR=blue]null[/COLOR]);
[COLOR=blue]return[/COLOR] View([COLOR=blue]await[/COLOR] EVAContext.ToListAsync());
Which whilst it would be nonsense is pushing an error on ToListAsync.
C#:
[COLOR=blue]var[/COLOR] EVAContext = _context.Job
.Include(j => j.Site)
.ThenInclude(j => j.WaterBodys)
[COLOR=green]// .ThenInclude(j=>j.WBName)[/COLOR]
.AsNoTracking()
.SingleOrDefaultAsync(j=>j.InvoiceDate!=1/1/0001 etc);
[COLOR=blue]return[/COLOR] View([COLOR=blue]await[/COLOR] EVAContext.ToListAsync());