0
我需要構建LINQ,但日(日期時間類型,i.AllowedTime.AllowedDate.Day),小時和分鐘(INT類型)存儲不同。我儘量做到:LINQ,不能構造日期時間
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
};
}
,但有一個例外:
{ 「日期部分時不按日期函數DATEADD數據 類型日期支持」}
怎麼做?
添加的類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; }
}
字段「時間」在數據庫中根本不存在。它是類MeetingModel2的屬性 – John 2012-02-08 13:00:32
什麼是'i.AllowedTime.AllowedDate.Day'的數據類型呢?我期望它是一個整數,但我沒有看到兩個整數的EntityFunctions.AddHours的重載。 – Arbiter 2012-02-08 14:22:04