Your LINQ query as written will only return records for the month prior to what is selected
x.Month == numberMonth-1
What you would need to do is alter this to be less than the selected month
x.Month < numberMonth
Now adding this information up is may be a little tricky. It appears that the
Overtime column in your table is of the
Time
data-type, and the Model you are using has this as a nullable string.
Now I understand that Overtime really isn't a time, it is a period of time; which .NET has natively. It is called a
TimeSpan
, and TimeSpans can added together.
Now you are going to need to review some documentation (see links below) and figure out how you are going to implement this.
If it was me; I would be changing the Model to the proper type and then just summing the values.
References:
TimeSpan Struct (System) | Microsoft Docs[
^]
TimeSpan.Add(TimeSpan) Method (System) | Microsoft Docs[
^]