<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Entity Framework Design : Stored Procedures</title><link>http://blogs.msdn.com/efdesign/archive/tags/Stored+Procedures/default.aspx</link><description>Tags: Stored Procedures</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using Stored Procedures to load structured data.</title><link>http://blogs.msdn.com/efdesign/archive/2008/07/18/using-stored-procedures-to-get-load-structured-data.aspx</link><pubDate>Fri, 18 Jul 2008 20:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8750530</guid><dc:creator>efdesign</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/efdesign/comments/8750530.aspx</comments><wfw:commentRss>http://blogs.msdn.com/efdesign/commentrss.aspx?PostID=8750530</wfw:commentRss><description>&lt;p&gt;V1 of the Entity Framework allows you to use stored procedures in two main ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Mapping Create, Update and Delete entity operations to appropriate stored procedures. &lt;/li&gt;
&lt;li&gt;Doing a FunctionImport that allows you to return an enumeration of Entities* &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Now the thing is, in order to return an enumeration of&amp;nbsp;Entities, you have to map the Entity too.&lt;/p&gt;
&lt;p&gt;Why? &lt;/p&gt;
&lt;p&gt;Well in V1 FunctionImport attaches the returned entities, so you can make and save changes.&lt;/p&gt;
&lt;p&gt;But of course sometimes you don't want that functionality, you just want a structured way of moving information around, so it is a shame to be required to do the mapping too.&lt;/p&gt;
&lt;p&gt;This leaves us two possibilities for V2.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Allowing FunctionImports to return unattached/untracked Entities. &lt;/li&gt;
&lt;li&gt;Allowing FunctionImports to return ComplexTypes. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The ComplexTypes option is the topic of the following one-pager by Asad a Program Manager on the Entity Framework team:&lt;/p&gt;
&lt;h3&gt;Scenario:&lt;/h3&gt;
&lt;h4&gt;Customer Goal:&lt;/h4&gt;
&lt;p&gt;The customer wants to do something like this in their .NET code:&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; color: blue;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CustomerInfo&lt;/span&gt; GetCustomerInfo(&lt;span style="color: blue;"&gt;int&lt;/span&gt; Id) &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;{ &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;NorthwindEntities &lt;/span&gt;ctx = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;NorthwindEntities&lt;/span&gt;()) &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{ &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerInfo&lt;/span&gt; info = ctx.GetCustomerInfoById(Id).FirstOrDefault(); &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; info; &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;} &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; line-height: 115%;" courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Without needing to create mappings&amp;nbsp;etc,&amp;nbsp;as this lowers the&amp;nbsp;level of friction inherent in using stored procedures for queries with the Entity Framework.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NB: today we only support Collection(Type) as the return type of the FunctionImport, which means it results in an Enumeration, hence the call to FirstOrDefault(). A separate work item is required to support returning just one ComplexType (or EntityType) rather than collections.&lt;/p&gt;
&lt;h3&gt;Detailed Scenario walk through:&lt;/h3&gt;
&lt;h4&gt;&lt;span style=""&gt;User defines a Stored Procedure in store:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt; &lt;/span&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;Create&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt; &lt;span style="color: blue;"&gt;Procedure&lt;/span&gt; GetCustomerInfoById&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style="color: gray;"&gt;( &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;@Id &lt;span style="color: blue;"&gt;int &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: gray;"&gt;) &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;As &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; first_name &lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;As &lt;/span&gt;Firstname&lt;span style="color: gray;"&gt;,&lt;/span&gt; last_name &lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;As &lt;/span&gt;Lastname&lt;span style="color: gray;"&gt;,&lt;/span&gt; city &lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;As &lt;/span&gt;City&amp;nbsp; &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; CustomerTable &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; id &lt;span style="color: gray;"&gt;=&lt;/span&gt; @Id&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;h4&gt;Complex type definition in EDM:&lt;/h4&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal;"&gt;&lt;span style="font-size: 11pt;"&gt;User wants to map the result set from this stored procedure to a Complex type “CustomerData” defined in Entity Data Model as: &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;ComplexType&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;CustomerData&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Property&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;Firstname&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;String&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;MaxLength&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;50&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Property&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;font color="#0000ff"&gt;Lastname&lt;/font&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;String&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;MaxLength&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;50&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Property&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"C&lt;span style="color: blue;"&gt;ity&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;String&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;MaxLength&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;50&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;ComplexType&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;The mapping involves following three steps:&lt;/h3&gt;
&lt;h4&gt;Define import function definition in SSDL:&lt;/h4&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Function&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;GetCustomerInfoById&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Aggregate&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;BuiltIn&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;NiladicFunction&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;IsComposable&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;false&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;ParameterTypeSemantics&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;AllowImplicitConversion&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Schema&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;dbo&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Parameter&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;Id&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;int&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Mode&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;In&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt;&lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Function&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;Expose function definition in CSDL schema file&lt;/h4&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;EntityContainer&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;CustomerEntityContainer&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&amp;nbsp;&lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;FunctionImport&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;GetCustomerInfoById&lt;/span&gt;"&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;ReturnType&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;Collection(Self.CustomerData)&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;Parameter&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;Id&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Mode&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;In&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Int32&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt;&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;FunctionImport&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;EntityContainer&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt; 
&lt;h4&gt;&lt;a class="" title="_Toc201594026" name="_Toc201594026"&gt;&lt;/a&gt;&lt;span style=""&gt;Define mapping (convention based) MSL file:&lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/h4&gt;
&lt;p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;EntityContainerMapping&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;StorageEntityContainer&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;StoreContainer&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;CdmEntityContainer&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;CustomerEntityContainer&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&amp;nbsp;&lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;FunctionImportMapping&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;FunctionImportName&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;GetCustomerInfoById&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;FunctionName&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;StoreNamespace.GetCustomerInfoById&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&amp;gt; &lt;br&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;EntityContainerMapping&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt; &lt;/span&gt;
&lt;/p&gt;&lt;h3&gt;Design Details:&lt;/h3&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 21.75pt; text-indent: -0.25in; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;span style=""&gt;-&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt;"&gt;Mapping between Complex type and result type is by convention. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 21.75pt; text-indent: -0.25in; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;span style=""&gt;-&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt;"&gt;Explicit property to column name mapping is not supported. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 21.75pt; text-indent: -0.25in; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;span style=""&gt;-&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt;"&gt;The result from the stored procedure has to exactly match the shape and the property names of the complex types. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 0pt 21.75pt; text-indent: -0.25in; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;span style=""&gt;-&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt;"&gt;In EDM the result is captured in a Complex type therefore no EntitySet definition or mapping is required.&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Assumptions/suppositions:&lt;/h3&gt;
&lt;p class="MsoListParagraph" style="margin: 0in 0in 0pt 21.75pt; text-indent: -0.25in; line-height: normal;"&gt;&lt;span style="font-size: 10pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;span style=""&gt;-&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt;"&gt;A future work item (covered by a separate feature entry) would enable richer mapping capability by allowing column renames. However for now Convention based mapping is the only supported feature.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Looking forward to hearing your feedback.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/alexj" mce_href="http://blogs.msdn.com/alexj"&gt;&lt;b&gt;Alex James&lt;/b&gt;&lt;/a&gt; &lt;br&gt;Program Manager, &lt;br&gt;Entity Framework Team&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;i&gt;This post is part of the transparent design exercise in the Entity Framework Team. To understand how it works and how your feedback will be used please look at &lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;a href="http://blogs.msdn.com/efdesign/archive/2008/06/23/transparency-in-the-design-process.aspx" mce_href="http://blogs.msdn.com/efdesign/archive/2008/06/23/transparency-in-the-design-process.aspx"&gt;this post&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;. &lt;/i&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;*In V1 it is also possible to do a FunctionImport that returns a scalar value, but this FunctionImport is not available in Object Services, if you want to use it you have to drop down to eSQL in the EntityServices layer.&amp;nbsp; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8750530" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/efdesign/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://blogs.msdn.com/efdesign/archive/tags/EDM/default.aspx">EDM</category><category domain="http://blogs.msdn.com/efdesign/archive/tags/Stored+Procedures/default.aspx">Stored Procedures</category><category domain="http://blogs.msdn.com/efdesign/archive/tags/Mapping/default.aspx">Mapping</category><category domain="http://blogs.msdn.com/efdesign/archive/tags/Entity+Framework+4/default.aspx">Entity Framework 4</category></item></channel></rss>