-1
This is the select of my proc
select f.id
,f.nome
,f.dataNascimento
,f.cpf
,f.cidade
,c.nome
from
funcionarios f inner join cidade c on f.cidade = c.id
and my model cidae is like this
public class Cidade
{
public Cidade()
{
Funcionarios = new List<Funcionario>();
}
[Key]
public int id { get; set; }
[Required]
public String nome { get; set; }
public virtual ICollection<Funcionario> Funcionarios { get; set; }
}
and the Funcionario model
public class Funcionario
{
[Key]
public int id { get; set; }
[Required]
public String nome { get; set; }
[Required]
public DateTime dataNascimento { get; set; }
[Required]
public long cpf { get; set; }
[Required]
public int cidade { get; set; }
[ForeignKey("cidade")]
public virtual int Cidade { get; set; }
}
When I consume the service that goes to the bank, I get this error
System.Invalidoperationexception: 'The Property 'city' cannot be configured as a navigation Property. The Property must be a Valid Entity type and the Property should have a non-abstract getter and Setter. For Collection properties the type must implement Icollection Where T is a Valid Entity type.'
Linq, the City camp is coming null at Postman. How do I bring the name of the city? In the bank proc returns, but in the mapping of the entity I do not know how to do this.
– pnet
Ah, there’s something else, right... Give a thrashing there, soon you find the mistake.
– Jéf Bueno
Not the name of FK, but returns me a Join from the bank and in this Join I get the name of the city, but I do not know how to get by mapping, be it in Postman or View
– pnet
OK.
– Jéf Bueno
I already solved it. Return in Proc
– pnet