<?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 : child viewmodel entity query</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : child viewmodel entity query</description>
  <pubDate>Wed, 29 Apr 2026 01:49:32 -700</pubDate>
  <lastBuildDate>Thu, 01 Oct 2009 12:17:46 -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=1474</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>child viewmodel entity query : Hi Greg, finally got back to this...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5551#5551</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=470" rel="nofollow">bigfish</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 01-Oct-2009 at 12:17pm<br /><br /><P>Hi Greg, finally got back to this with some details that make more sense.&nbsp; Firstly, thanks for pointing out FourSimpleSteps sample, that provided some insight and now I can get it to work. <BR>&nbsp;<BR>In your sample, you have wired up the code behind.&nbsp; You have created a CustomerList class.&nbsp; You got a handle to the DomainModelEntityManager for second time within that class <U>via a new login which I think is the key here</U>.&nbsp; From memory you're using IList and binding the combobox to Name(string) properties on both sides.<BR>&nbsp;<BR>In my situation I need to use IDictionary, swapping Name properties with FK ids of Int32 datatypes which imposes more complication around the binding manager, data context of the dataform and associated viewmodel (in prism) and also dataconverters to facilitate matching Int32 values with valid key/value pairs in the combobox dictionary. For storage and retrieval performance of course.<BR>&nbsp;<BR>That complication being said, I created the Dictionary as a public property of the viewmodel associated with the view, not a separate class altogether as in your sample.&nbsp; This approach made it simpler for binding manager to use a DataContextProxy to assist navigating the viewmodel properties.<BR>&nbsp;<BR>The upshot of your sample and the winning formula was the declaration to get another handle to the DomainModelEntityManager within the CustomerList class.&nbsp; Essentially, this enables a query to be run with is an EntityQuery within its own context, not (it seems) filtered by its parent.&nbsp; In my earlier post I was suspecting DF was doing NavigationQuery.</P><P>As a result, I have amended my code to use a NEW&nbsp; DomainModelEntityManager instance in each instantiation of the viewmodel, and now my combobox populates as I need.</P><P>However, is this the right thing to do architecturally.&nbsp; I fear scalability will be severely impacted here.&nbsp; As I construct a new child form to edit row details, a new instance of DomainModelEntityManager is created.&nbsp; 20 edits, 20 new instances as evidenced in the log file as UserName = Default Principal - 1, 2, 3, 4 etc.</P><P>Your FourSimpleSteps code uses DomainModelEntityManager manager = DomainModelEntityManager.DefaultManager - which is not a new instance, but a separate login is used.</P><P>If I use .DefaultManager, it's the same as using the current dmem instance I have already, so it won't work.&nbsp; I have to use = new DomainModelEntityManager(); each time to overcome NavigationQuery issues I've mentioned.</P><P>Can you shed some more light on whether I should use this approach, or if there is some other way I can use the same single DomainModelEntityManager instance throughout the entire application yet provide ability to choose whether an Entity Query works in the context of NavigationQuery OR full EntityQuery unencumbered with its navigation neighbors.<BR>&nbsp;<BR></P>]]>
   </description>
   <pubDate>Thu, 01 Oct 2009 12:17:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5551#5551</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : Oh, wait, sorry, I see from your...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5449#5449</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 22-Sep-2009 at 9:57am<br /><br />Oh, wait, sorry, I see from your picture that your ComboBox is on a DataForm rather than a DataGrid. But in any event, the MainFormIntermediate in the FourSimpleSteps tutorial solution in the LearningResources uses a ComboBox for the editing template of an Orders grid column that shows the selected Order's parent Customer. To activate the editing template, the user has to double-click in the Customer column. All Customers in the database are available in the item list, but the cell is bound to a single Customer at any given time.<br><br>That one is in a grid, but the basic wiring and population of the Combobox are the same in a DataForm. Perhaps you can look at how the ComboBox is configured there, and tell me if there's anything substantially different about your situation.<br><br><br>]]>
   </description>
   <pubDate>Tue, 22 Sep 2009 09:57:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5449#5449</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : Sorry, bigfish, I&amp;#039;ve just...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5447#5447</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 22-Sep-2009 at 9:44am<br /><br />Sorry, bigfish, I've just sort of gotten lost in the trees in this one. Have you been able successfully to wire up a simple ComboBox in a Silverlight DataGrid, with nothing else going on?<br>]]>
   </description>
   <pubDate>Tue, 22 Sep 2009 09:44:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5447#5447</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : Hi Greg, any further thoughts...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5443#5443</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=470" rel="nofollow">bigfish</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 21-Sep-2009 at 9:14pm<br /><br />Hi Greg, any further thoughts on this please?<DIV>&nbsp;</DIV><DIV>While I've played around with it a lot, still no luck from my end.</DIV><DIV>&nbsp;</DIV><DIV>I've created a view of the AssetComponent table, no relationship constraints therefore, but in this case zero rows are returned.&nbsp; I suspect that the Dataform Control on the ChildUserControl limits the child viewmodel query to only those of the dataform's currentitem....&nbsp; ie the scope is being constrained in the binding mechanism before the IB query can be fired.</DIV><DIV>&nbsp;</DIV><DIV>The code used to call the form (same as in Prism Explorer) is:</DIV><DIV>&nbsp;</DIV><DIV><FONT size=2><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>void</FONT></FONT><FONT size=2> EditAsset()</P><P>{</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>var</FONT></FONT><FONT size=2> viewModel = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>AssetViewModel</FONT></FONT><FONT size=2>(QueryRepository) {SelectedAsset = SelectedAsset };</P><P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>var</FONT></FONT><FONT size=2> assetView = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>AssetView</FONT></FONT><FONT size=2>(viewModel);</P><P>assetView.Show();</P><P>}</P><DIV>&nbsp;</DIV><DIV>I suspect I will need to generate the AssetComponent collection prior to this method, and pass it in as part of the constructor as is the SelectedAsset above if I am to avoid the IB query being constrained (if that is what is happening).&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>Your thoughts please?</DIV><DIV>&nbsp;</DIV></FONT></DIV>]]>
   </description>
   <pubDate>Mon, 21 Sep 2009 21:14:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5443#5443</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : Hi Greg, thanks.  the main PK/FK...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5430#5430</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=470" rel="nofollow">bigfish</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 18-Sep-2009 at 11:46am<br /><br />Hi Greg, thanks.<DIV>&nbsp;</DIV><DIV>the main PK/FK relationship of concern here is the one between Asset and AssetComponent.</DIV><DIV>&nbsp;</DIV><DIV>Asset.assetComponentID(int)(fk) -&gt; AssetComponent.assetComponentID(int)(pk)</DIV><DIV>&nbsp;</DIV><DIV>Asset.propertyID(int)(fk) -&gt; Property.propertyID(int)(pk)</DIV><DIV>&nbsp;</DIV><DIV>AssetComponent.assetTypeID(int)(fk) -&gt; AllType.allTypeID(int)(pk)</DIV><DIV>AssetComponent.assetZoneID(int)(fk) -&gt; AllType.allTypeID(int)(pk)</DIV><DIV>&nbsp;</DIV><DIV>These ones are likely irrelevant for the problem at hand but exist nonetheless</DIV><DIV>Property.councilTypeID(int)(fk) -&gt; AllType.allTypeID(int)(pk)</DIV><DIV>Property.propertySourceID(int)(fk) -&gt; AllType.allTypeID(int)(pk)</DIV><DIV>Property.areaTypeID(int)(fk) -&gt; AllType.allTypeID(int)(pk)</DIV>]]>
   </description>
   <pubDate>Fri, 18 Sep 2009 11:46:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5430#5430</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : Bigfish:Can you please specify...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5427#5427</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 18-Sep-2009 at 9:08am<br /><br />Bigfish:<br><br>Can you please specify which columns are foreign keys for each of the relationships? Since the naming conventions are not very regular, I'd rather not guess.<br>]]>
   </description>
   <pubDate>Fri, 18 Sep 2009 09:08:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5427#5427</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : Thanks Greg, I think I was not...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5409#5409</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=470" rel="nofollow">bigfish</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 17-Sep-2009 at 1:38pm<br /><br /><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0.75pt">Thanks Greg, I think I was not very clear in my post. </DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt"></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">The relationship in the database is so:</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;<img src="http://www.ideablade.com/forum/uploads/470/Image1.jpg" height="415" width="748" border="0" /></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt"></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">The application exposes a house(property) and its assets:</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt"></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;<img src="http://www.ideablade.com/forum/uploads/470/Image2.jpg" height="230" width="849" border="0" /></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">Editing one row (one asset) at a time exposes a Child window:</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt"><img src="http://www.ideablade.com/forum/uploads/470/Image3.jpg" height="321" width="522" border="0" /></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt"></DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">In that child Window&nbsp;collection of AssetComponents is needed and while the attempt to gather these via the following query is made, only a single value is returned:&nbsp; that of the parent Asset row....&nbsp;&nbsp;I think EM is doing navigation query, not entity query.</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0.75pt 1.5pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">public void GetAssetComponents(Action&lt;IEnumerable&gt; callback) {</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0pt">IEntityQuery&lt;AssetComponent&gt; assetComponentQuery = Manager.AssetComponents</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.4pt 0pt 73.45pt">.Include("AssetType")</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.4pt 0pt 73.45pt">.Include("AssetZone");</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.4pt 0pt 73.45pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0pt">Manager.ExecuteQueryAsync(assetComponentQuery, args =&gt; callbackAssetComponent(args, callback), null);</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">&nbsp;}</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0pt">This query is issued from the child window's viewmodel.&nbsp; The child window has on it a dataform, current item set to the current selected asset.</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0pt">&nbsp;</DIV><DIV style="LINE-HEIGHT: normal; MARGIN: 0cm 1.5pt 0.75pt">Further help to overcome this will be very much appreciated.</DIV><DIV style="MARGIN: 0cm 0cm 10pt">&nbsp;</DIV>]]>
   </description>
   <pubDate>Thu, 17 Sep 2009 13:38:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5409#5409</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : The entity with the foreign key...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5406#5406</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 17-Sep-2009 at 12:17pm<br /><br />The entity with the foreign key is the child.&nbsp; Suppose, for example, that you have an Order entity that belongs to a Customer. A Customer can have many Orders, but each Order has only one Customer.&nbsp; Order is the child in the relationship; Customer the Parent. In the database, Order has a foreign key pointing to a particular Customer record.<br><br>It sounds like you want to pick a parent from your ComboBox; e.g., while viewing the details of an Order, you want to assign a Customer to be the owner of that Order.<br><br>The ItemsSource for your customer ComboBox needs to be a collection that includes all Customers. You will never get that collection from the Customer navigation property of Order.&nbsp; You should get it from an independent query like<br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; List&lt;Customer&gt; customers = entityManager.Customers<br><br><br><br>]]>
   </description>
   <pubDate>Thu, 17 Sep 2009 12:17:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5406#5406</guid>
  </item> 
  <item>
   <title>child viewmodel entity query : I have a child view/viewmodel...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5396#5396</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=470" rel="nofollow">bigfish</a><br /><strong>Subject:</strong> 1474<br /><strong>Posted:</strong> 16-Sep-2009 at 3:04pm<br /><br /><P>I have a child view/viewmodel that issues an entity query.&nbsp; </P><DIV>The child view is instantiated from an EDIT function from its parent view, grid row (identical to your&nbsp;Prism Explorer actually).</DIV><DIV>&nbsp;</DIV><DIV>The child viewmodel entity query is used to populate a combobox.&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>As such, the entity query needs to return a collection of all records from the datasource.&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>Currently it acts as if its a navigation query, returning only a collection that is constrained (filtered) by the parent row.&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>There is a database constraint in place.&nbsp; Parent table FK id is dependant on valid PK values from child table.</DIV><DIV>&nbsp;</DIV><DIV>Is it possible to override or avoid this constraint in the query mechanism?&nbsp;I want the child view/viewmodel to provision a collection of all child table values, regardless of the parent table FK value.&nbsp; </DIV><DIV>&nbsp;</DIV><DIV>I've tried to issue various querystrategies to avoid this with no joy. In fact the Entity Manager does not even&nbsp;perform a query if a querystrategy.datasourceonly (or other) is included, I think becasue it realises its going to only perfrom navigation query, so ignores it altogether as an invalid query construct.</DIV><DIV>&nbsp;</DIV><DIV>The same query works fine and returns expected results if I plug it into Prism Explorer QueryRepository.&nbsp; There, there is no constraint from a parent row.</DIV><DIV>&nbsp;</DIV><DIV>Also, none of the queries from the child viewmodel end up in the debug log.&nbsp; Is this because its a navigation query, not entity query?</DIV><DIV>&nbsp;</DIV><DIV>Thanks if you can help.</DIV><DIV>Rgds</DIV>]]>
   </description>
   <pubDate>Wed, 16 Sep 2009 15:04:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1474&amp;PID=5396#5396</guid>
  </item> 
 </channel>
</rss>