【发布时间】:2016-10-21 06:59:39
【问题描述】:
select * from Employees where DataofJoin ='2005-01-01 00:00:00.000'
我把这个 Linq 查询写成
public JsonResult Dif()
{
var ss = Convert.ToDateTime("2001-01-01 00:00:00.000");
var x = (from n in db.Employees
where n.DataofBirth == ss
select n).First();
return new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
但它抛出以下错误:
"An exception of type 'System.InvalidOperationException' occurred in System.Core.dll
but was not handled in user code"
【问题讨论】:
-
请向我们展示您的堆栈跟踪
-
什么是 StackTrce
-
题主完全误导,与Sql Datetime查询转换无关
-
我不明白你的代码应该做什么。您实例化一个 DataTime 对象,进行 linq 查询,将结果存储在 x 中并返回一个新的 JsonResult。但是您永远不会将 x 的值分配给任何东西。
标签: c# linq model-view-controller