Lets say I need to fetch some records from the database, and filter them based on an enumeration type property.
- fetch
List<SomeType> - filter on
SomeType.Size - enumeration
Size { Small, Medium, Large }
when displaying records, there will be a predefined value for Size filter (ex Medium). In most of the cases, user will select a value from filtered data by predefined value.
There is a possibility that a user could also filter to Large, then filter to Medium, then filter to Large again.
I have different situations with same scenario:
- List contains less than 100 records and 3-5 properties
- List contains 100-500 records and 3-5 properties
- List contains max 2000 records with 3-5 properties
What is my best approach here? Should I have a tab that will contain grid for each enum, or should I have one common enum and always filter, or?
I would do the filtering right on the database, if those fields are indexed I would suspect having the db filter it would be much faster than filtering with c-sharp after the fact.
Of course you can always cache the filtered database result as to prevent multiple unnescessary database calls.
EDIT: as for storing the information in the database, suppose you had this field setup:
then in your C#
In this example, the table
TshirtSizesis only used for the reader to know what the magic numbers 1, 2, and 3 mean. If you don’t care about database read-ability you can omit those tables and just have an indexed column.