title: decoupled generic key-value access against linq in a non-xml environment
body: <p>good morning.</p>
  
  <p>i am not a computer scientist by education, so please overlook any shady term abuse.</p>
  
  <p>in my framework, a base form called Record opens form RecordDetail as dialog. for example, RecordClient extends Record and contains client data and tabbed lists of client-relevant child data, and RecordDetail expands one child data row for detailed editing based wholly on reflection and display overrides stored as custom attributes used against DataContext. Record is subclassed for the application, but i see no need to subclass RecordDetail. this works except for the display of foreign key edits in the listed children.</p>
  
  <p>i <em>must</em> use <a href="http://objectlistview.sourceforge.net/cs/index.html" rel="nofollow">ObjectListView</a> and Linq; i cannot use WPF/XML. because i do the serialization trick for non-continuous database connectivity, i lose foreign key objects when i clone data to manage state. ObjectListView needs the foreign key object for display and general wickedness. i know Hibernate, but Linq leaves me at a loss:</p>
  
  <p>how might i access the foreign key object from within Record after its dialog to RecordDetail closes - without coupling framework and application-specific classes?</p>
  
  <p>that is,</p>
  
  <pre><code>Type rowType = row.GetType();
  IDomain workDamnit = (IDomain)dataContextReflectedFromRowType.GetTable(rowType).Where(x =&gt; x.PrimaryKey == 1).SingleOrDefault();
  </code></pre>
  
  <p>where "PrimaryKey" wraps the primary key attribute, and the fail happens between "GetTable", "Where" and "SingleOrDefault".</p>
  
  <p>any perspective appreciated on this fine sunday morning.</p>