<?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 : Multiple Model Query</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Multiple Model Query</description>
  <pubDate>Sun, 12 Apr 2026 08:51:08 -700</pubDate>
  <lastBuildDate>Mon, 23 Jan 2012 16:25:38 -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=3227</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>Multiple Model Query :    Hi Vincent,While you can...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3227&amp;PID=12532#12532</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 3227<br /><strong>Posted:</strong> 23-Jan-2012 at 4:25pm<br /><br />Hi Vincent,<div>&nbsp;</div><div>While you can have an EntityManager with multiple models pointing to different datasources, you can only query one database at the time. (You can, however, save multiple entities to multiple databases in one single transaction)</div><div>&nbsp;</div><div>So, you will need to first retrieve the customers and then query for the orders. (or vice versa)</div><div>&nbsp;</div><div>i.e</div><div>&nbsp;</div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> aCustomer = mgr.Customers.First();</font></font></div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> aCustomerOrders = mgr.Orders.Where(ord =&gt; ord.CustomerID == aCustomer.Id)</font></font></div><div><font size="2"><font face="C&#111;nsolas">&nbsp; .ToList();</font></font></div><div><font size="2"><font face="C&#111;nsolas"></font></font>&nbsp;</div><div><font size="2"><font face="C&#111;nsolas">or</font></font></div><div><font size="2"><font face="C&#111;nsolas"></font></font>&nbsp;</div><div><font size="2"><font face="C&#111;nsolas"><font color="#0000ff"><font color="#0000ff"><font color="#0000ff">var</font></font></font></font><font face="C&#111;nsolas"> myOrder = mgr.Orders.First();</font></font></div><div><font size="2"><font color="#0000ff"><font color="#0000ff"><font color="#0000ff" face="C&#111;nsolas">var</font></font></font><font face="C&#111;nsolas"> CustomerName = mgr.Customers.Where(cust =&gt; cust.Id == myOrder.CustomerID)</font></font></div><div><font size="2" face="C&#111;nsolas">&nbsp; .Select(cust =&gt; cust.CompanyName)</font></div><div><font size="2" face="C&#111;nsolas">&nbsp; .Distinct();</font></div><div>&nbsp;</div><div>You might want to take a look at the <a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/many-models-per-manager" target="_blank">DevForce Resource Center</a> for more information.</div><div>I've also attached a simple solution showing one EntityManager with multiple models. (<a href="http://www.ideablade.com/forum/uploads/892/T11435.zip" target="_blank">uploads/892/T11435.zip</a>)</div><div>&nbsp;</div><div>&nbsp;</div><div>Regards,</div><div>&nbsp;&nbsp; Silvio.</div>]]>
   </description>
   <pubDate>Mon, 23 Jan 2012 16:25:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3227&amp;PID=12532#12532</guid>
  </item> 
  <item>
   <title>Multiple Model Query : In my application I have two models....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3227&amp;PID=12517#12517</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=791" rel="nofollow">Vincent</a><br /><strong>Subject:</strong> 3227<br /><strong>Posted:</strong> 21-Jan-2012 at 8:56am<br /><br />In my application I have two models. One model contains customer entity and another contains order entity. These models are coming from different databases. Can you please give me a sample linq query of how I can retrieve particulars of an order showing its customer name?<DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Best Regards,</DIV><DIV>Vincent</DIV>]]>
   </description>
   <pubDate>Sat, 21 Jan 2012 08:56:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3227&amp;PID=12517#12517</guid>
  </item> 
 </channel>
</rss>