<?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 : Stored Proc Queries</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Stored Proc Queries</description>
  <pubDate>Tue, 12 May 2026 22:30:50 -700</pubDate>
  <lastBuildDate>Sun, 06 Jan 2013 14:14:42 -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=3876</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>Stored Proc Queries :    EF doesn&amp;#039;t yet support...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3876&amp;PID=15514#15514</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3876<br /><strong>Posted:</strong> 06-Jan-2013 at 2:14pm<br /><br />EF doesn't yet support mapping to stored procedures, but it does have a back door which you can take advantage of in DevForce.&nbsp; The "back door" is described here - <a href="http://msdn.microsoft.com/en-us/data/jj592907" target="_blank">http://msdn.microsoft.com/en-us/data/jj592907</a> - and involves using the DbSet.SqlQuery method.&nbsp; The SqlQuery method allows you to write a raw SQL query or call a stored procedure.<div>&nbsp;</div><div>Since stored procedures can't be mapped to your model you can't use the DevForce StoredProcQuery, which under the hood expects to call the ObjectContext.ExecuteFunction method.</div><div>&nbsp;</div><div>You can use an RPC method, although it might be some work to push entities into an EntityCacheState and return that.&nbsp; Using an RPC method would be best for stored procedures not returning entities.</div><div>&nbsp;</div><div>It's probably best to use DevForce's named query support.&nbsp; DevForce supports both "default" and custom named queries, and includes support for parameters.&nbsp; Using a named query, you provide the actual implementation for the query, and DevForce will call this when you execute a query from the client EntityManager.</div><div>&nbsp;</div><div>You write a simple query provider, and in a named query method call the DbSet.SqlQuery method with your SQL.&nbsp; For example, here's a query provider which implements the default named query for the Product entity (from the CodeFirstWalk sample) and calls a stored procedure named "Get_Products":</div><div>&nbsp;</div><div>&#091;EnableClientAccess&#093;<br>public class NamedQueryServiceProvider {</div><div>&nbsp; public IEnumerable&lt;Product&gt; GetProducts() {<br>&nbsp;&nbsp;&nbsp; using (var context = new ProductDbContext("CodeFirstWalk")) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var products = context.Products.SqlQuery("dbo.Get_Products").ToList();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return products;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>}</div><div>&nbsp;</div><div>More info on named queries is here - <a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/named-query" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/named-query</a>.</div><div>&nbsp;</div><span style="font-size:10px"><br /><br />Edited by kimj - 06-Jan-2013 at 2:15pm</span>]]>
   </description>
   <pubDate>Sun, 06 Jan 2013 14:14:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3876&amp;PID=15514#15514</guid>
  </item> 
  <item>
   <title>Stored Proc Queries :   HelloIs it possible to execute...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3876&amp;PID=15512#15512</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=118" rel="nofollow">LowOrbit</a><br /><strong>Subject:</strong> 3876<br /><strong>Posted:</strong> 06-Jan-2013 at 11:15am<br /><br />Hello<div>&nbsp;</div><div>Is it possible to execute a StoredProcQuery:</div><div>&nbsp;</div><ol><li>When you model is done in Code First? I see examples when doing it Model First but cannot find any examples when the model is Code First. If so, could you provide a simple example of the mappings, etc., that need to be done?</li><li>On the server side from an RPC function? If so, are there any special changes/configurations versus what is done in question 1?</li></ol><p>Thanks!</p>]]>
   </description>
   <pubDate>Sun, 06 Jan 2013 11:15:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3876&amp;PID=15512#15512</guid>
  </item> 
 </channel>
</rss>