I'm working on an application that imports video files and lets the user browse them and filter them based on various conditions. By importing I mean creating instances of my VideoFile
model class and storing them in a DB table. Once hundreds of files are there, the user wants to browse them.
Now, the first choice they have in the UI is to select a DateRecorded
, which calls a GetFilesByDate(Date date)
method on my data access class. This method will query the SQL database, asking only for files with the given date.
On top of that, I need to filter files by, let's say, FrameRate
, Resolution
or UserRating
. This would place additional criteria on the files already filtered by their date. I'm deciding which road to take:
- Only query the DB for a new set of files when the desired
DateRecorded
changes. Handle all subsequent filtering manually in C# code, by iterating over the stored collection of_filesForSelectedDay
and testing them against current additional rules. - Query the DB each time any little filter changes, asking for a smaller and very specific set of files more often.
Which one would you choose, or even better, any thoughts on pros and cons of either of those?
Some additional points:
- A query in
GetFilesByDate
is expected to return tens of items, so it's not very expensive to store the result in a collection always sitting in memory. - Later down the road I might want to select files not just for a specific day, but let's say for the entire month. This may give hundreds or thousands of items. This actually makes me lean towards option two.
- The data access layer is not yet implemented. I just have a dummy class implementing the required interface, but storing the data in a in-memory collection instead of working with any kind of DB.
- Once I'm there, I'll almost certainly use SQLite and store the database in a local file.