I want to use two Queried for selected data to one getJSON data.
how to return Multiple Objects Using ASP.NET MVC JsonResult Class.
public ActionResult GetData()
{
var quertt = db.StoreSalesTotals.Where(x=>x.Date.Month==1 && x.Date.Year == 2022).Select(g => new { name = g.Date, count01 = g.LAFS, count02 = g.NYFS, count03 = g.SJFS, count04 = g.Date }).OrderBy(x => x.count04).ToList();
var quertt01 = db.StoreSalesTotals.Where(x => x.Date.Month == 1 && x.Date.Year == 2021).Select(g => new { name01 = g.Date, count001 = g.LAFS, count002 = g.NYFS, count003 = g.SJFS, count04 = g.Date }).OrderBy(x => x.count04).ToList();
var valuea = new { quertt, quertt01 }; // it is not working with two data.
return Json(valuea, JsonRequestBehavior.AllowGet);
}
{
<script type="text/javascript">
$(document).ready(function () {
$.getJSON("/Store_Inv/GetData", function (data) {
var Names = [];
var LAFS = [];
var NYFS = [];
var SJFS = [];
for (var i = 0; i < data.length; i++) {
Names.push(data[i].quertt.name);
LAFS.push(data[i].count01);
NYFS.push(data[i].count02);
SJFS.push(data[i].count03);
}
Highcharts.chart('container', {
chart: {
type: 'line'
},
title: {
text: 'Daily Sales Graph'
},
subtitle: {
text: 'GenMon USA'
},
xAxis: {
categories: Names
},
yAxis: {
title: {
text: 'Sales'
}
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: true
}
},
series: [{
name: 'NYFS',
data: NYFS
},
{
name: 'LAFS',
data: LAFS
},
{
name: 'SJFS',
data: SJFS
}]
});
});
});
</script>
}