您好我需要运行以下命令 查询和组日期时间字段仅由日期值。
var startDateTime = regDate.Date;
var endDateTime = regDate.AddSeconds(fullDayinSeconds);
var res = from u in ObjectContext.Member.Where(o => o.RegisterTime >= startDateTime && o.RegisterTime <= endDateTime)
group u by new { u.PartnerId, u.RegisterTime.Date, u.partners.Name } into pgroup
let count = pgroup.Count()
select new PartnersUsersInfo
{
PartnerId = pgroup.Key.PartnerId.GetValueOrDefault(0),
PartnerName = pgroup.Key.Name, PartnerUsersAmount = count
};
u.RegisterTime.Date
- 返回异常 LINQ to Entities不支持指定的类型成员'Date'。
我曾尝试使用EntityFunctions.TruncateTime
,但不能接受群组操作。
如何解决?
答案 0 :(得分:1)
您可以尝试添加带有日期和分组的临时颜色
答案 1 :(得分:0)
使用
db.CallLogs.Where(r =&gt; DbFunctions.TruncateTime(r.DateTime)== callDateTime.Date)。ToList();