有誰知道我能得到我的結果目前在QRY的IQueryable對象爲格式交錯數組:幫助有需要的鐵血陣列,獲得IQueryable的結果到一個數組
series:
[{
name: '2',
data: [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
}, {
name: '3',
data: [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 3, 0]
}]
我的問題是我的代碼目前所面對的環繞在12元數據部分的雙引號,也就是它看起來像這樣在客戶端上的調試器:
導致[0] {...} [0]:「2」 [1]:「[0,0,0,0,0,0,1,0,0,0,0,0]」 ?結果[1] {...} [0]:「3」 [1]:「[1,0,0,0,0,0,0,0,0,0,0,0]」
問題是我的數組包含一個單一的字符串元素,而不是一個12個數字的數組。
這裏是目前返回12號部分爲一個大的字符串我控制器代碼:
var qry = from i in _db.Complaints
where i.Site.SiteDescription.Contains(searchTextSite)
&& (i.Raised >= startDate && i.Raised <= endDate)
group i by i.ComplaintNatureTypeId.ToString()
into grp select new
{
Type = grp.Key,
Count = "[" + grp.Where(c => c.Raised.Month == 1).Count() + "," +
grp.Where(c => c.Raised.Month == 2).Count() + "," +
grp.Where(c => c.Raised.Month == 3).Count() + "," +
grp.Where(c => c.Raised.Month == 4).Count() + "," +
grp.Where(c => c.Raised.Month == 5).Count() + "," +
grp.Where(c => c.Raised.Month == 6).Count() + "," +
grp.Where(c => c.Raised.Month == 7).Count() + "," +
grp.Where(c => c.Raised.Month == 8).Count() + "," +
grp.Where(c => c.Raised.Month == 9).Count() + "," +
grp.Where(c => c.Raised.Month == 10).Count() + "," +
grp.Where(c => c.Raised.Month == 11).Count() + "," +
grp.Where(c => c.Raised.Month == 12).Count() + "]"
};
return Json(qry.ToArray(), JsonRequestBehavior.AllowGet);
我想我需要創建一個數組和循環QRY對象,但問題是12個數字的排列是一個字符串。與此聯繫在一起的人提出了一種方法,非常感謝 – John