Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linq 林克,can';t构造日期时间_Linq_Asp.net Mvc 3_Entity Framework 4_Linq To Entities - Fatal编程技术网

Linq 林克,can';t构造日期时间

Linq 林克,can';t构造日期时间,linq,asp.net-mvc-3,entity-framework-4,linq-to-entities,Linq,Asp.net Mvc 3,Entity Framework 4,Linq To Entities,我需要构造linq,但是day(日期时间类型,I.AllowedTime.AllowedDate.day)、小时和分钟(int类型)的存储方式不同。我努力做到: DateTime date = DateTime.Now.Date; IQueryable<ITW2012Mobile.Core.DataTable.MeetingModel2> result = null; if (status == MeetingStatus.Reques

我需要构造linq,但是day(日期时间类型,I.AllowedTime.AllowedDate.day)、小时和分钟(int类型)的存储方式不同。我努力做到:

        DateTime date = DateTime.Now.Date;
        IQueryable<ITW2012Mobile.Core.DataTable.MeetingModel2> result = null;
        if (status == MeetingStatus.RequestedOfYou)
        {

            result = from i in _dbContext.Meetings
                     where i.UserInvitedID == CurrentUserID && i.MeetingStatus == null && EntityFunctions.TruncateTime(i.AllowedTime.AllowedDate.Day) >= date
                     select new ITW2012Mobile.Core.DataTable.MeetingModel2()
                     {
                         Name = i.UserInviter.FirstName + " " + i.UserInviter.LastName,
                         Company = i.UserInviter.Company,
                         MeetingID = i.MeetingID,
                         Time = EntityFunctions.AddMinutes(EntityFunctions.AddHours(i.AllowedTime.AllowedDate.Day, i.AllowedTime.Hour).Value, i.AllowedTime.Minute).Value,
                         Image = i.UserInviter.ProfileImage,
                         Username = i.UserInviter.aspnet_User.UserName
                     };
        }

您要查询的数据库中的字段“Time”可能是数据类型。不能执行时间操作,如向日期类型添加分钟或小时。如果您将该字段更改为a,您可能会没事。

DB中根本不存在字段“时间”。它是class MeetingModel2的属性“i.AllowedTime.AllowedDate.Day”的数据类型是什么?我希望它是一个整数,但我没有看到需要两个整数的EntityFunctions.AddHours重载。
public class MeetingModel2
{
    public int MeetingID { get; set; }
    public string Name { get; set; }
    public string Company { get; set; }
    public DateTime Time { get; set; }
    public string Image { get; set; }
    public string Username { get; set; }
}