0
I’m only trying to get a 1 record of the Phones and Emails lists.
var lista = Db.Oportunidades
.Include(x => x.Conta.Proprietario)
.Include(x => x.Conta.Contatos.Select(c => c.Telefones))
.Include(x => x.Conta.Contatos.Select(c => c.Emails))
.Include(x => x.Estado)
.Include(x => x.Motivo)
.Include(x => x.Tipo);
I’ve tried to use First()
, Sigle()
, Take(1)
that generate the error below.
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. Name of parameter: path
Any hint?
I believe this link can help you: https://stackoverflow.com/questions/38676029/the-include-path-expression-must-refer-to-a-navigation-property-defined-on-the-t
– Alan César
You probably have to use something like this: var list = Db.Opportunities . Include(x => x.Conta.Proprietary) . Include(x => x.Conta.Contacts) . Include(x => x.Status) . Include(x => x.Reason) . Include(x => x.Type) . Select(c => new { Phone = x.Conta.Contacts.Select(c => c.Phones). First(), Email = x.Conta.Contacts.Select(c => c.Emails). First(), }). Tolist();
– Carlos Scherer