title: In C#, is there out-of-the-box way to build a 3-way lookup table?
body: <p>I have an in-memory "table" that might looks something like this:</p>
  
  <pre><code>Favorite#  Name        Profession
  ---------  ----------  ------------------
  3          Names.Adam  Profession.Baker
  9          Names.Bob   Profession.Teacher
  7          Names.Carl  Profession.Coder
  7          Names.Dave  Profession.Miner
  5          Names.Fred  Profession.Teacher
  </code></pre>
  
  <p>And what I want to do, is do quick and efficient lookups, using any of the 3 fields.
  In other words, I want:</p>
  
  <ul>
  <li><code>myTable[3]</code> and <code>myTable[Names.Adam]</code> and <code>myTable[Professions.Baker]</code> to all return <code>{3,Names.Adam,Profession.Baker}</code></li>
  <li><code>myTable[Profession.Teacher]</code> to return both <code>{9,Names.Bob,Profession.Teacher}</code> and <code>{5,Names.Fred,Profession.Teacher}</code>.</li>
  </ul>
  
  <p>The table is built during runtime, according to the actions of the user, and cannot be stored in a database since it is used in sections in which database connectivity cannot be guaranteed.</p>
  
  <p>Right now, I "simply" (hah!) store this using 3 uber-Dictionaries, each keyed using one of the columns (FavoriteNumber, Name, Profession), and each value in the uber-Dictionaries holding 2 Dictionaries which are themselves keyed with each of the remaining columns (so the values in the "Name" uber-dictionary are of the type <code>Dictionary&lt;FavoriteNumber,Profession[]&gt;</code> and <code>Dictionary&lt;Profession, FavoriteNumber[]&gt;</code></p>
  
  <p>This requires 2 lookups in 2 Dictionaries, and another traverse of an array (which usually holds 1 or 2 elements.)</p>
  
  <p>Can anyone suggest a better way to do this? I don't mind spending extra memory, since the table is likely to be small (no more than 20 entries) but I'm willing to sacrifice a little CPU to make it more readily maintainable code...</p>