1

我需要这样做:

context.Ads.Where(c => c.PublishedDate.HasValue &&
        c.EndDate.HasValue &&
        c.EndDate.Value.AddTicks(c.PublishedDate.Value.Ticks) > currentTime &&
        c.AdStatusMail.Where(b => b.StatusKey != (int)AdStatusMailKey.EndedRemainder && b.StatusKey != (int)AdStatusMailKey.MiddleRemainder).Count() < 1)
        .ToList();

问题是 AddTicks 不能在 Linq 中使用。我看过 EntityFunctions 但看不到如何使用它来做我需要的事情?

4

1 回答 1

1

IQueryable 无法处理刻度,使其成为 IEnumerable(或 tolist)。这是一个例子:

context.Ads.Where(c => c.PublishedDate.HasValue && c.EndDate.HasValue && c.AdStatusMail.Where(b => b.StatusKey != (int)AdStatusMailKey.EndedRemainder && b.StatusKey != (int)AdStatusMailKey.MiddleRemainder).Count() < 1)
           .AsEnumerable()
           .Where (c => c.EndDate.Value.AddTicks(c.PublishedDate.Value.Ticks) > currentTime)
           .ToList();
于 2012-11-02T18:34:44.810 回答