I have the following query.
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. Can anyone see why Visual Studio seems to get confused here?
