我需要构建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
};
}
但有例外:
{&#34;数据的日期函数dateadd不支持datepart小时 输入日期。&#34;}
怎么做?
ADDED类MeetingModel2
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; }
}