I want to do a select with where or where and I'm trying to do as follows, but when I execute this method
public JsonResult JSONInfoFinTriMonths3()
{
using (DBEnt db = new DBEnt())
{
//Select(m => m.Name).Distinct();
var categorias = db.HomeInfoFinanciera.Where(s => s.month == 7 && s.month == 8 && s.month == 9);
return Json(categorias, JsonRequestBehavior.AllowGet);
}
}
Here I have the query that generates me
SELECT
[Extent1].[id] AS [id],
[Extent1].[created_at] AS [created_at],
[Extent1].[lastupdate] AS [lastupdate],
[Extent1].[id_userCreated] AS [id_userCreated],
[Extent1].[tipo] AS [tipo],
[Extent1].[path] AS [path],
[Extent1].[year] AS [year],
[Extent1].[month] AS [month],
[Extent1].[day] AS [day]
FROM [dbo].[HomeInfoFinanciera] AS [Extent1]
WHERE [Extent1].[month] IN (7,8,9)
which just returns me all the data I want.
Here I am calling the method
$.ajax({
url: "/Home/JSONInfoFinTriMonths3",
type: "GET",
dataType: "json",
//contentType: "application/json; charset=utf-8",
success: function (response) {
console.log(response)
//alert(response);
var resplength = response.length;
for (let i = 0; i <= resplength; i++) {
document.getElementById('months1div')
.innerHTML += `
<li data-filter=".filter-${response[i].year}">
${response[i].year}</li>
`;
}
},
error: function (jqXHR, textStatus, err) {
//$('#myModalLabel').append(`error: - ${err}`);
console.log(jqXHR);
console.log(textStatus);
console.log(err);
alert(jqXHR.responseJSON + "JSONInfoFinYears");
}
});
But i get the error
alert(jqXHR.responseJSON + "JSONInfoFinYears");
If it's of interest to someone learning, I ended up doing this with Native SQL https://www.entityframeworktutorial.net/Querying-with-EDM.aspx