<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Obtaining Navigation Properties by Reflection?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Obtaining Navigation Properties by Reflection?</description>
  <pubDate>Wed, 13 May 2026 21:38:41 -700</pubDate>
  <lastBuildDate>Wed, 17 Aug 2011 15:23:40 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2904</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Obtaining Navigation Properties by Reflection? : Hi Robert, Thanks for your quick...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2904&amp;PID=11458#11458</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1181" rel="nofollow">jradxl</a><br /><strong>Subject:</strong> 2904<br /><strong>Posted:</strong> 17-Aug-2011 at 3:23pm<br /><br />Hi Robert,<br>Thanks for your quick reply, and your considered response.<br><br>Can I offer this, which will illustrated what I was trying....<br><br>With DF 6.1.2 (and EF 4.1) we are moving to not having a .edmx file, by using Code First.<br><br>But we have a T4 code generator (for non DF things) that consumes the .edmx in an equally complex way within VS2010.<br><br>Now that VS2010 SP1 does not lock DLLs while they are being used within T4, I was obtaining the model by reflection.<br>It's working extremely well, and the Dev, Test, Debug cycle is very easy and quick, whether one is changing the Model, it's partial classes or the T4 template.<br><br>But until I tried I didn't realise that the Navigation info is so difficult to obtain from the model assembly by reflection.<br>I think the info the code generator needs will need to be added manually in a partial class in a similar form to your CustomerMetadata approach - pity, was hoping I could make it "automatic".<br><br>thanks<br>John<br>]]>
   </description>
   <pubDate>Wed, 17 Aug 2011 15:23:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2904&amp;PID=11458#11458</guid>
  </item> 
  <item>
   <title>Obtaining Navigation Properties by Reflection? : John,  It sounds like you&amp;#039;re...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2904&amp;PID=11457#11457</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1097" rel="nofollow">robertg</a><br /><strong>Subject:</strong> 2904<br /><strong>Posted:</strong> 17-Aug-2011 at 2:14pm<br /><br />John,<DIV>&nbsp;</DIV><DIV>It sounds like you're trying to do something very complex, which means there's always the possibility of unforeseen difficulties. Would you mind providing some more information on what you're trying to accomplish? Are you trying to override&nbsp;code generation?</DIV><DIV>&nbsp;</DIV><DIV>In general, filtering against the "Navigation" string for&nbsp; your properties should be pretty safe, since you're using it against generated code. It's certainly what I'd do.</DIV><DIV>&nbsp;</DIV><DIV>If you can&nbsp;provide some more information on your use-case,&nbsp;we'll think it through a bit more to make sure it does match your need, though. It may be that there's another technique you could use which is more straight-forward than building a model of your model with reflection.&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Yours</DIV><DIV>Robert</DIV>]]>
   </description>
   <pubDate>Wed, 17 Aug 2011 14:14:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2904&amp;PID=11457#11457</guid>
  </item> 
  <item>
   <title>Obtaining Navigation Properties by Reflection? : Hi,Assuming the typical DF technique...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2904&amp;PID=11453#11453</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1181" rel="nofollow">jradxl</a><br /><strong>Subject:</strong> 2904<br /><strong>Posted:</strong> 17-Aug-2011 at 12:36pm<br /><br />Hi,<br>Assuming the typical DF technique of putting the .edmx and the generated .cs in an Assembly, I want to find the Navigation properties by reflection over the Assembly DLL (for code generation reasons during development).<br><br>Of course I can find all the members of the NestedProperty, PropertyMetadata but the only way I can think of deciding whether there are navigation properties is to look for the part word Navigation in the FieldType.<br><br><pre style="font-family:C&#111;nsolas;font-size:13;color:black;:white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Type</span>&nbsp;myType&nbsp;=&nbsp;<span style="color:blue;">typeof</span>(MyDomainModel.<span style="color:#2b91af;">MyEntity</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">var</span>&nbsp;nestedtypes&nbsp;=&nbsp;myType.GetNestedType(<span style="color:#a31515;">"PropertyMetadata"</span>,&nbsp;<span style="color:#2b91af;">BindingFlags</span>.Public);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">var</span>&nbsp;navproperties&nbsp;=&nbsp;nestedtypes.GetFields().Where(f&nbsp;=&gt;&nbsp;f.FieldType.Name.Contains(<span style="color:#a31515;">"Navigation"</span>));</pre>Is that robust?<br>Is there a better way?<br><br>thanks<br>John<br><br>]]>
   </description>
   <pubDate>Wed, 17 Aug 2011 12:36:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2904&amp;PID=11453#11453</guid>
  </item> 
 </channel>
</rss>