I have a table in RAM (from DB + file) with 20+ fields and 100K+ rows. So i need search rows by 6 differents fields. What the best structure for this task in C#?
- Using List is bad because searching too long.
- Using external software (as elastic search) is not good because task used once per day, and no other reason to use external hard software
- Using 6 tuples is possible but not nice solution
I used 6 Dictionary and can merged it in one custom class, but may be .net has another structure (builded or nuget) about i dont know
The best approach is probably to use the database instead of reinventing the wheel. Databases may run completely in memory, or efficiently cache tables in memory for fast queries. Some databases can also run in process. See for example SQLite in memory. Make sure to have indices for the columns used for searching. Replicating the same functionality is probably not worth the effort unless you have some very special requirements that are difficult to implement with a database.
If you insist on writing this yourself the simplest option is probably to just use multiple dictionaries. To avoid storing multiple copies of a row you can use dictionaries that map a key to a index in a common list used by all dictionaries. Note that regular dictionaries cannot store multiple values for the same key, see MultiValueDictionary if that is needed.