A simple LINQ query:
from transport in db.Transports
select new
{
Current = transport.CurrentLocation,
CurrentCarriers = transport.CurrentLocation.Carriers,
};
Problem: CurrentLocationmay be zero. If so, executing this request causes a NullReference. I tried adding a check, for example
transport.CurrentLocation == null ? null : transport.CurrentLocation.Carriers
but Linq to sql doesn't seem to be able to parse it.
Any good solutions that are not related to sending an additional request for each transport?
source
share