<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Loading related entities for ObjectResult (stored procedure)</title>
	<atom:link href="http://blog.cincura.net/230720-loading-related-entities-for-objectresult-stored-procedure/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cincura.net/230720-loading-related-entities-for-objectresult-stored-procedure/</link>
	<description>Taking something that can&#039;t be done, and then doing it.</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:02:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: KShan</title>
		<link>http://blog.cincura.net/230720-loading-related-entities-for-objectresult-stored-procedure/#comment-5362</link>
		<dc:creator>KShan</dc:creator>
		<pubDate>Sat, 26 Feb 2011 19:05:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230720#comment-5362</guid>
		<description>Fixed it! I was using MergeOption.NoTracking and so it was not updating. Works with MergeOption.OverwriteChanges</description>
		<content:encoded><![CDATA[<p>Fixed it! I was using MergeOption.NoTracking and so it was not updating. Works with MergeOption.OverwriteChanges</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KShan</title>
		<link>http://blog.cincura.net/230720-loading-related-entities-for-objectresult-stored-procedure/#comment-5361</link>
		<dc:creator>KShan</dc:creator>
		<pubDate>Sat, 26 Feb 2011 18:27:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230720#comment-5361</guid>
		<description>Great article! I was able to adapt it (mostly) for an ObjectContext with POCO&#039;s but I find that even if loads the related entity (I see the query go by in Profiler) the related entites are not populated. You mentiod it should be fine for ObjectQuery. So I am not sure what I am missing. Do you think you might be able to help?

This is a simplified edition of yours (with a lot of stuff hard coded for proof of concept):

		public static void MyLoadProperty2(this ObjectContext objectContext, TEntity entity, string navigationProperty) where TEntity : class
		{
			ObjectQuery query = objectContext.ObjectStateManager.GetRelationshipManager(entity).GetRelatedEnd(&quot;FK_Customer_has_Orders&quot;, navigationProperty).CreateSourceQuery() as ObjectQuery;

			Type related = query.GetType().GetGenericArguments()[0];

			typeof(ObjectContextExtensions)
				.GetMethod(&quot;LoadRelatedHelper2&quot;, System.Reflection.BindingFlags.NonPublic &#124; System.Reflection.BindingFlags.Static)
				.MakeGenericMethod(related)
				.Invoke(null, new object[] { query, MergeOption.NoTracking });
		}

		private static void LoadRelatedHelper2(ObjectQuery query, MergeOption mergeOption)
			where TRelated : class
		{
			query.Context.CreateQuery(&quot;select value v from orders as v where v.Customer_RecordID = @Customer_RecordID&quot;, new ObjectParameter(&quot;Customer_RecordID&quot;, new Guid(&quot;FAD85849-6631-4B71-A311-58C1DF3E515F&quot;))).Execute(mergeOption).ToArray();
		}</description>
		<content:encoded><![CDATA[<p>Great article! I was able to adapt it (mostly) for an ObjectContext with POCO&#8217;s but I find that even if loads the related entity (I see the query go by in Profiler) the related entites are not populated. You mentiod it should be fine for ObjectQuery. So I am not sure what I am missing. Do you think you might be able to help?</p>
<p>This is a simplified edition of yours (with a lot of stuff hard coded for proof of concept):</p>
<p>		public static void MyLoadProperty2(this ObjectContext objectContext, TEntity entity, string navigationProperty) where TEntity : class<br />
		{<br />
			ObjectQuery query = objectContext.ObjectStateManager.GetRelationshipManager(entity).GetRelatedEnd(&#8220;FK_Customer_has_Orders&#8221;, navigationProperty).CreateSourceQuery() as ObjectQuery;</p>
<p>			Type related = query.GetType().GetGenericArguments()[0];</p>
<p>			typeof(ObjectContextExtensions)<br />
				.GetMethod(&#8220;LoadRelatedHelper2&#8243;, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)<br />
				.MakeGenericMethod(related)<br />
				.Invoke(null, new object[] { query, MergeOption.NoTracking });<br />
		}</p>
<p>		private static void LoadRelatedHelper2(ObjectQuery query, MergeOption mergeOption)<br />
			where TRelated : class<br />
		{<br />
			query.Context.CreateQuery(&#8220;select value v from orders as v where v.Customer_RecordID = @Customer_RecordID&#8221;, new ObjectParameter(&#8220;Customer_RecordID&#8221;, new Guid(&#8220;FAD85849-6631-4B71-A311-58C1DF3E515F&#8221;))).Execute(mergeOption).ToArray();<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cincura.net</title>
		<link>http://blog.cincura.net/230720-loading-related-entities-for-objectresult-stored-procedure/#comment-1952</link>
		<dc:creator>cincura.net</dc:creator>
		<pubDate>Sun, 23 Aug 2009 16:54:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230720#comment-1952</guid>
		<description>Uhm, this may be related to the association problem described in article.</description>
		<content:encoded><![CDATA[<p>Uhm, this may be related to the association problem described in article.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://blog.cincura.net/230720-loading-related-entities-for-objectresult-stored-procedure/#comment-1951</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Sun, 23 Aug 2009 16:51:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230720#comment-1951</guid>
		<description>Interesting.  I am using EFExtensions with intity also and when I insert with a stored procedure the context does not pick up the associates for the new object.</description>
		<content:encoded><![CDATA[<p>Interesting.  I am using EFExtensions with intity also and when I insert with a stored procedure the context does not pick up the associates for the new object.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

