Reputation: 65870
var invoice = (from i in Catalog.Invoices
where (i.Id == invoiceId)
select i)
.Include(i => i.Appointment.Service)
.Include(i => i.Appointment.Allocations.Select(a => a.Service))
.Include(i => i.Appointment.Allocations.Select(e => e.Employee))
.FirstOrDefault();
var inv = invoice.Appointment.Allocations.Select(e => e.Employee);
My Question : How to filter the null values from above query ?
Upvotes: 0
Views: 1867
Reputation: 18102
You should add a Where
clause to the query to filter out the null
values.
Either after the Select
:
var inv = invoice.Appointment.Allocations.Select(e => e.Employee).Where(e => e != null);
or before the Select
:
var inv = invoice.Appointment.Allocations.Where(e => e.Employee != null).Select(e => e.Employee);
Upvotes: 2