Let's say I have a List<Type>
and a Type
with the properties:
public DateTime OriginalDateTime { get; set; }
public double RoundedTime { get; }
public int MyValue { get; set; }
And that class contains a constructor:
public Match(DateTimeOffset dateTime, int bid, int ask, int volume)
{
DateTime = dateTime;
RoundedTime = Math.Round(Math.Ceiling(dateTime.ToTimeStamp() / 60) * 60); // Round to nearest minute
Bid = bid;
Ask = ask;
Volume = volume;
}
Now using LINQ
and GroupBy
I get all the results grouped by RoundedTime
. No problem, however, I want to check if there is a result for every minute (so for an hour of data, the GroupBy
should return 60 results).
Preferably, when a minute is missing from the LINQ
result, I'd like to use the previous value (let's say minute 30 is missing, fill it with the data of minute 29).
Now I'm wondering if this is even possible with LINQ
.
TakeWhile()
where minute < 30 (or whatever), thenLastOrDefault
.