I want to take only 1 client with 3 invoices from the DB. The code stated below does not give me 3 results(but throws an exception).
Exception: The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties. Parameter name: path
There is one Client which can have multiple Invoices, one Invoice which can have multiple InvoiceLines.
I want to retrieve one Client with 3 Invoices and the associated InvoiceLines.
What did i do wrong here?
public async Task<Client> Client(int id)
{
using (var db = GetContext())
{
return await db.Client.Include(x => x.Invoices.Take(3))
.Where(i => !i.IsDeleted)
.Include(c => c.Invoices.Select(x => x.InvoiceLines))
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
}
}