'Find if list is sequential and with timestamp to today

Using Entity Framework Core 6 I have the entity:

public class Node {
  public String Parameter { get; set; }
  public String Period { get; set; }
  public Decimal Value { get; set; }
  public DateTimeOffset Timestamp { get; set; }
}

The Period value can be:

M1 = 1 Minute
H1 = 1 Hour
D1 = 1 Day

For each pair (Parameter, Period) I need to find if I have the most recent 200 values.

For example, I need to find if I have the temperature for the previous 200 days:

Parameter = Temperature
Period = D1

I need to check all the pairs that don't satisfy this condition. I started with:

 var stored = _context.Nodes
  .GroupBy(x => new { x.Parameter, x.Period })
  .Select(x => new { 
     Parameter = x.Key.Parameter, 
     Period = x.Key.Period, 
     Count = x.Count() 
  });

With this I have the count for each pair.

But I am not sure if they are sequential and reaching today.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source