I have situation where in the Repository class I have a dictionary:
Dictionary<TableName, Dictionary<EntityColumnName, SourceColumnName> map1 = new Dictionary<TableName, Dictionary<EntityColumnName, SourceColumnName> ()
with methods for manipulating data (Get,Save,Add etc).
Now there is a need to search by value from the inner map, not only by key (in this example SourceColumnName
).
My question is what would be best approach here? I want to add another dictionary but with reversed data:
Dictionary<TableName, Dictionary<SourceColumnName, EntityColumnName> map2 = new Dictionary<TableName, Dictionary<SourceColumnName, EntityColumnName> ()
But the problem is memory usage, is that a waste of memory? But if I implement lookup by value, I'll lose the main advantage of dictionary.
The data stored in the dictionary is around 20 * 5k data in the inner map. Any suggestion how to design / refactor this class would be appreciated.
EDIT1: Micro optimisation post didn't resolved my problem. I work on project where optimisation is very important.