Im not sure if the title fully explains what I am after here so let me try explain in a little more detail…
I need to be able to create an table that displays this…
Tables:
- Items (every time this item was installed and removed)
- Supplier (Every time the supplier was used with the item)
- Rate (rate for the supplier)
It needs to be able to:
- Get the ranges in the period selected
- Get the earliest date from the tables as the start date
- Get the latest date
If the start dates are all before the start period and all the end dates are after the end period then it will be a simple single line. But any dates that start or end in the middle of the period then set relevant dates for that line and get the next start date after previous line end.
I have done the entire program using Linq apart from this and I have something that looks like it works but Im really not happy with the way Iv done it.
My questions are… whats an elegant way of dealing with these dates? And should I be using C# or SQL Server for best result?

first glade to see someone working at energy management industry.
Unfortunately, I don’t quite understand your question, however, my suggestion is:
“Move the generate/retrieve data logic down a layer”
The performance: SQL Server > .Net > LINQ
The functionality of LINQ is very limited and not easy to deal with.
Have you tried to use SQL Stored Procedure to bring back a set of data?
Functions inside SQL Query like
case statementandmin group bycan easily solve your problem.In this case, SQL Server will bring back intended data to C#, then C# just need a way to present these data.