Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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-再次输入日期时间字符串_Linq_Asp.net Mvc 3 - Fatal编程技术网

LINQ-再次输入日期时间字符串

LINQ-再次输入日期时间字符串,linq,asp.net-mvc-3,Linq,Asp.net Mvc 3,我有以下代码: result = from i in _dbContext.Meetings where i.UserInvitedID == CurrentUserID && i.MeetingStatus == null && i.AllowedTime.AllowedDate.Day >= date //where i.UserInvitedID

我有以下代码:

            result = from i in _dbContext.Meetings
                     where i.UserInvitedID == CurrentUserID && i.MeetingStatus == null && i.AllowedTime.AllowedDate.Day >= date
                     //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.ToString("0:dddd, MMMM d, yyyy 0:t"),
                         Image = i.UserInviter.ProfileImage,
                         Username = i.UserInviter.aspnet_User.UserName
                     };
时间是弦。当然,我明白了

异常错误:{LINQ to Entities无法识别该方法 “System.String-ToString”方法,此方法不能为空 已翻译为存储表达式。}

但是在我的例子中如何正确地书写呢?

在L2E中根本不能使用.ToString。这是EF限制


您必须在对象空间中执行此操作-例如,在.AsEnumerable

之后,我如何执行此操作?在选择部分中,我必须设置时间,对吗?你可以这样做:选择新的{A=I.A,B=I.B}.AsEnumerable.Selecti=>new MeetingModel2{A=I.A.ToString…,B=I.B;将是非常长的脚本,我有大约10个相似的位置,不能合并在一起。另一个选项是在数据库中创建一个计算列。