Ваш запрос выглядит хорошо. Просто проблема в предложении where (where trace.EntryDate == null || trace == null
).
Пример:
1. Если вам нужно условие WHERE, попробуйте -
var VehiclesStatus = (from veh in db.Sec_Vehicle
join tracing in db.Sec_Tracing on veh.Id equals tracing.CarId into trc
from trace in trc.Where(f => f.EntryDate== null).DefaultIfEmpty()//use :f.EntryDate== null if you need which has no EntryDate OR f.EntryDate!= null if you need which has EntryDate
orderby veh.Brand
select new VehicleStatus
{
Brand = veh.Brand,
Driver = trace != null ? trace.DriverName : string.Empty,
ReleaseDate = trace != null ? trace.ReleaseDate.ToString("HH:mm") : "",
Status = trace != null ? "Vehicle Busy" : "Vehicle Available"
}).ToList();
2. Без условия
var VehiclesStatus = (from veh in db.Sec_Vehicle
join tracing in db.Sec_Tracing on veh.Id equals tracing.CarId into trc
from trace in trc.DefaultIfEmpty()
orderby veh.Brand
select new VehicleStatus
{
Brand = veh.Brand,
Driver = trace != null ? trace.DriverName : string.Empty,
ReleaseDate = trace != null ? trace.ReleaseDate.ToString("HH:mm") : "",
Status = trace != null ? "Vehicle Busy" : "Vehicle Available"
}).ToList();