Using NET 6 with <Nullable>enable</Nullable>
in my project definition I have:
if (!(await _context?.Applications.AnyAsync())) {
}
I get the tip "_context might be null here" and this why I'm using ?
on it.
I am getting a warning:
Dereference of a possibly null reference.
I also tried:
if (!(await _context?.Applications.AnyAsync()) ?? false) {
}
But that does not compile. How can I solve this?
CodePudding user response:
Try this:
if (_context != null && !(await _context.Applications.AnyAsync())) {
}