I have a database with about 3 milion records, each record has id (int, primary key), uniqueNumber(int) and updateTime(string).
uniqueNumber can belong to several records. updateTime represents the time of the day the record was updated such as 14:33:42
EDIT: the records are ordered by update time.
I want to let the user define a uniqueNumber and an interval. Then I want to query the DB to get all the records belongs to that uniqueNumber where their updateTime is equal to a variable which it's value is increasing by interval each time the where condition is true.
For example, I want something like this: (there is no DB used in this example)
string currentTime = "12:25:00";
int interval = 2;
public void LinqExample()
{
string[] arr = new string[4] { "12:23:00", "12:26:00", "12:27:00", "12:28:00"};
var query = from c in arr
where c.Replace(":", "").CompareTo(currentTime.Replace(":", "")) > 0 && Inc()
select c;
// query's output is: "12:26:00", "12:28:00"
}
private bool Inc()
{
currentTime = DateTime.Parse(currentTime).AddMinutes(interval).ToLongTimeString();
return true;
}
is my code is the proper way to do this?
thanks!