C#Linq查询。日期之间的日期不起作用

时间:2020-03-25 16:14:39

标签: c# linq date filter

我尝试了两种方法仅从日期框架中选择日期,但仍然得到错误的结果。我看到了另一篇文章,但回复对我不起作用。请帮助我。

 List<Measurement> measurementsForTemplate = await databaseCommandContext.CreateSet<Measurement>()
                .Include(v => v.MeasuredValues)
                .Where(x => x.MeasurementFormTemplateId == command.TemplateId )
                .Where(v => v.MeasuredValues.Any(d => d.Time >= command.FromDate))
                .Where(v => v.MeasuredValues.Any(d => d.Time <= command.ToDate)).ToListAsync(cancellationToken);

或者我在上面的查询中创建了一个没有过滤的对象,然后

    var measurementsForTemplateDateLimit = measurementsForTemplate.Where(b => b.MeasuredValues
    .Any(d => d.Time >= command.FromDate && d.Time <= command.ToDate)).Select(b => b);

1 个答案:

答案 0 :(得分:0)

有关解决方案,请参见下图 enter image description here