你好我试图在我的查询中减去两个DateTimes并将defference与timeInterval进行比较,但我得到了exeption:
<Message>An error has occurred.</Message>
<ExceptionMessage>System.TimeSpan Subtract(System.DateTime)</ExceptionMessage>
<ExceptionType>System.NotSupportedException</ExceptionType>
C#代码:
producerRelations = producerRelationRepository.Query().Fetch(c => c.Order).
Where(c => c.Order.CreatedBy == login).
Where(c=>currentDate.Subtract(c.RouteUnit.DtStart.Value).TotalMinutes<timeInterval);
如何在代码中减去日期?
答案 0 :(得分:0)
使用AsEnumerable
producerRelations = producerRelationRepository.Query().Fetch(c => c.Order).
Where(c => c.Order.CreatedBy == login).AsEnumerable().
Where(c=>currentDate.Subtract(c.RouteUnit.DtStart.Value).TotalMinutes<timeInterval);
或者您需要使用EntityFunctions