我想获取所有每月过期的产品,这是查询:
_customerProductsRepository
.Where(
d =>
!d.ReleaseDate.HasValue &&
EntityFunctions.AddMonths(d.RenewalDate ?? d.AcquireDate, 1) < now)
.ToArray();
AcquireDate是产品的第一次购买,RenewalDate是产品的最后一次续订。
由于某种原因,它转换为以下 SQL:
SELECT
[Extent1].[CustomerDidId] AS [CustomerDidId],
[Extent1].[DidNumber] AS [DidNumber],
[Extent1].[CountryId] AS [CountryId],
[Extent1].[CustomerId] AS [CustomerId],
[Extent1].[AcquireDate] AS [AcquireDate],
[Extent1].[ReleaseDate] AS [ReleaseDate],
[Extent1].[RenewalDate] AS [RenewalDate],
[Extent1].[RenewalNotificationDate] AS [RenewalNotificationDate]
FROM [dbo].[CustomerDids] AS [Extent1]
WHERE ([Extent1].[ReleaseDate] IS NULL) AND ((DATEADD (month, 1, [Extent1].[Rene
walDate])) < @p__linq__0)
应该有一个案例陈述提到'??' 而是签名 - 它完全删除了 AcquireDate 列。
我怎样才能在它周围走来走去?