I have this method that makes me a select but it does not return anything to me.
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public JsonResult GetContratos()
{
List<object> resultado = new List<object>();
var contratos = db.Contratos.Where(c => c.Tipo != "N").Select(c => c.Id);
foreach (string contrato in contratos)
{
resultado.Add(new { id = contrato, value = contrato });
}
return Json(resultado, JsonRequestBehavior.AllowGet);
}
I have tried to put the .ToList () in the end and nothing
The SQL that is returned to me in the variable var contratos
, when I execute it in sql server it works perfectly, it gives me back, but in C # it does not bring me anything.
{SELECT
1 AS [C1],
[Extent1].[Id] AS [Id],
[Extent1].[DtCriacao] AS [DtCriacao],
[Extent1].[DtInicioValidade] AS [DtInicioValSELECT
[Extent1].[Id] AS [Id]
FROM [dbo].[Contrato] AS [Extent1]
WHERE NOT ((N'N' = [Extent1].[Tipo]) AND ([Extent1].[Tipo] IS NOT NULL))