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