我有datetime变量officeStartTime
,其日期时间值为
officeStartTime = {9/24/2013 10:00:00 AM}
我有模块CHECKINOUT
包含userid
,checktime
和其它性质.
现在我想要的是获取CHECKINOUT
其时间部分检查时间大于时间部分的条目列表officeStartTime
.
我尝试:
var checklist= con.CHECKINOUTs.Where(x => x.CHECKTIME.TimeOfDay > officeStartTime.TimeOfDay);
checklist
包含以下错误:
{"The specified type member 'TimeOfDay' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."}
.
它表示TimeOfDay
在LINQ to Entities中不支持,如果是这样,我如何在LINQ中检查日期时间的一部分.有没有其他方法可以做到这一点?请建议我做什么.
谢谢.
我是mvc的新手,我在一个控制器的方法中加载ViewBag,
HomeController: Controller
{
Public ActionResult Index()
{
loadViewBag();
return View();
}
public void loadViewBag()
{
ViewBag.aaa = "something";
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常.
我的问题是,现在我想调用loadViewBag()方法形成另一个控制器(比如Account),这样我就可以重用同样的方法,并且由于一些静态变量需要使loadViewBag()方法静态:
public static void loadViewBag()
如果我使用loadViewBag方法静态,ViewBag上出现错误" 非静态字段,方法或属性'System.Web.Mvc.ControllerBase.ViewBag.get' " 需要对象引用.
有没有解决方案/建议.
谢谢.