You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var railcarInfo = await (from rt in DbContext.RailcarTrips
where rt.WaybillRailcar.RailcarNumber == clm.RailcarNumber &&
rt.WaybillRailcar.Waybill.CreateDate <= clm.SightingDate
orderby rt.WaybillRailcar.Waybill.CreateDate descending
select new
{
RailcarTrip = rt,
WaybillCreateDate = rt.WaybillRailcar.Waybill.CreateDate,
IsLoaded = rt.WaybillRailcar.Weight > 0
})
.AsNoTracking()
.FirstOrDefaultAsync();
But for some reason, Visual Studio decides that 'railcarInfo' is not null here immediately following this query.
The point of FirstOrDefaultAsync() is that it returns the first item in a collection, or null if the collection is empty. It could definitely be null here. Seems Visual Studio got confused?
Include provider and version information
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 11
IDE: Visual Studio 2019 16.11.5
The text was updated successfully, but these errors were encountered:
@SoftCircuits the FirstOrDefaultAsync operator is part of EF Core, and EF Core wasn't annotated for nullable reference types. Try EF Core 6.0 RC2, it should work there.
I have the following query.
But for some reason, Visual Studio decides that 'railcarInfo' is not null here immediately following this query.
The point of
FirstOrDefaultAsync()
is that it returns the first item in a collection, or null if the collection is empty. It could definitely be null here. Seems Visual Studio got confused?Include provider and version information
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Windows 11
IDE: Visual Studio 2019 16.11.5
The text was updated successfully, but these errors were encountered: