0
这是我正在工作的代码我想知道当使用mvc图表时这两种情况是否可能?而如何去这样做他们如何计算工作时间的总和和日期格式,只显示mvc使用mvc图表助手的月份
我控制器
public ActionResult CharterColumn()
{
ArrayList xValue = new ArrayList();
ArrayList yValue = new ArrayList();
var results = (from c in db.Timesheets select c);
results.ToList().ForEach(rs => xValue.Add(rs.Date));
//I want to format this to show the only the months on the x axis
results.ToList().ForEach(rs => yValue.Add(rs.Hours));
//And I want to calculate the sum of the hours for each month worked by a specific employee
new Chart(width: 800, height: 400, theme: ChartTheme.Yellow)
.AddTitle("Test")
.AddSeries("Default", chartType: "Column", xValue: xValue, yValues: yValue)
.Write("bmp");
return null;
}
和我的观点
<div>
<img src= "@Url.Action("CharterColumn")" alt="Chart"/>
</div>
“System.NotSupportedException”类型的异常出现在EntityFramework.SqlServer.dll但在用户代码 其他信息没有处理:LINQ到实体无法识别方法'System.String GetAbbreviatedMonthName(Int32)'方法,并且此方法不能转换为存储表达式。嗨,我已经试过它得到这个错误 – Kimberly
@Kimberly尝试没有'dtfi',如最后所述。我认为你必须在linq查询之前执行'.ToList()'。 – adiga
附加信息:LINQ to Entities不识别方法'System.String ToString(System.String)'方法,并且此方法不能转换为存储表达式。 – Kimberly