2
I have the following method:
However, when I run the query in the Log, using the left Join I get the following message :
Dbcomparisonexpression requires Arguments with comparable types
[HttpGet]
[Route("findAll")]
public HttpResponseMessage findAll()
{
try
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
var tamanho = (from bc in bdprincipalEntities.tamanho
join c in bdprincipalEntities.fornecedor on bc.for_codigo
equals c.For_codigo into c_c
from c in c_c.DefaultIfEmpty()
join d in bdprincipalEntities.GrupoProduto on bc.GrupoProduto_Codigo
equals d.GrupoProduto_Codigo into d_bc
from d in d_bc.DefaultIfEmpty()
select new
{
Tam_codigo = bc.Tam_codigo,
Tam_descricao = bc.Tam_descricao,
GrupoProduto_Descricao = d.GrupoProduto_Descricao,
For_Nome = c.For_Nome,
for_codigo = bc.for_codigo,
tam_CodFor = bc.tam_CodFor,
Emp_codigo = bc.Emp_codigo,
Tam_situacao = bc.Tam_situacao.Equals("A") ? "ATIVO" : "DESATIVADO"
}).ToList();
result.Content = new StringContent(JsonConvert.SerializeObject(tamanho));
result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
return result;
}
catch (Exception ex)
{
return new HttpResponseMessage(HttpStatusCode.BadRequest);
}
}
The fields I am comparing are of type int:
public Nullable<int> for_codigo { get; set; } //Da tabela tamanho
public int For_codigo { get; set; } // Da tabela fornecedor
public Nullable<int> GrupoProduto_Codigo { get; set; } // Da tabela Tamanho
public int GrupoProduto_Codigo { get; set; } // Da tabela Grupo de Produto
I understood, but even changing the properties happens the same error
– Jeff Henrique
Strange...I suggest you make one
query
isolated only with theleft join
who’s in trouble. , playing the result on a new list, to isolate and be able to smooth better, sometimes it may be up to something else that is causing the error.– Gean Miguel
I’ll do, just finish one thing, but I was analyzing, the names aren’t exactly the same, could that be? for_code and for_code
– Jeff Henrique