LINQ join producing null reference error suddenly
I have a LINQ que开发者_Python百科ry which has the below joins
join v in dc.Vehicles on c.VehicleReg equals v.VehicleReg into vg
from v in vg.DefaultIfEmpty()
join vt in dc.VehicleTypes on v.VehicleType equals vt.ID into vtg
from vt in vtg.DefaultIfEmpty()
Now this worked perfect before, but it seems all of a sudden it's returning an object reference error trying to join vehicle into vehicletype when v is null. This worked before, and had the effect of making vtg null - which is ideal.
Any ideas?
The simple answer would probable filter null Vehicles
join v in dc.Vehicles.Where(v => v != null) on c.VehicleReg equals v.VehicleReg into vg
Hope that helps
精彩评论