<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Entity Framework Design</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/efdesign/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/efdesign/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 24 Feb 2016 13:26:05 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Entity Framework Design Blog Retired</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/entity-framework-design-blog-retired</link>
      <pubDate>Tue, 05 Jun 2012 10:33:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2012/06/05/entity-framework-design-blog-retired/</guid>
      <description><![CDATA[Over the last year we&rsquo;ve seen a marked increase in traffic on the ADO.NET blog, which has...]]></description>
      <content:encoded><![CDATA[<p>Over the last year we&rsquo;ve seen a marked increase in traffic on the <a href="https://blogs.msdn.com/adonet">ADO.NET blog</a>, which has encouraged us to use it for all our announcements and discussions. Today we are officially retiring the Entity Framework Design Blog, although we remain committed to the same transparent design process that was its <a href="https://blogs.msdn.com/b/efdesign/archive/2008/06/23/transparency-in-the-design-process.aspx">original purpose</a>. Stay tuned to the <a href="https://blogs.msdn.com/adonet">ADO.NET blog</a> to learn more about new features and to help us shape the future of Entity Framework.</p>
<p>Entity Framework Team</p>]]></content:encoded>
    </item>
    <item>
      <title>Enums in the Entity Designer</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/enums-in-the-entity-designer</link>
      <pubDate>Fri, 12 Aug 2011 15:48:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/08/12/enums-in-the-entity-designer/</guid>
      <description><![CDATA[One of the most highly-requested features for the Entity Framework is first-class support for...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: 0pt;" class="MsoNormal">One of the most highly-requested features for the Entity Framework is first-class support for Enums, and we are happy to provide support for this feature in the Entity Designer in the June 2011 CTP recently released. If you haven&rsquo;t checked it out already, find the bits here:</p>
<p style="margin-bottom: 0pt;" class="MsoNormal"><a href="https://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=26660">https://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=26660</a></p>
<p style="margin-bottom: 0pt;" class="MsoNormal"><br />We&rsquo;d like to give you a look at the experience of developing with Enum types in the Entity Designer. If you haven&rsquo;t yet, take a look at what is going on under the hood with Enums in the Entity Framework in the blog post here:</p>
<p style="margin-bottom: 0pt;" class="MsoNormal"><a href="https://blogs.msdn.com/b/efdesign/archive/2011/06/29/enumeration-support-in-entity-framework.aspx">https://blogs.msdn.com/b/efdesign/archive/2011/06/29/enumeration-support-in-entity-framework.aspx</a></p>
<p style="margin-bottom: 0pt;" class="MsoNormal">and you can follow an example of using Enums in the Walkthrough here:</p>
<p style="margin-bottom: 0pt;" class="MsoNormal"><a href="https://blogs.msdn.com/b/adonet/archive/2011/06/30/walkthrough-enums-june-ctp.aspx">https://blogs.msdn.com/b/adonet/archive/2011/06/30/walkthrough-enums-june-ctp.aspx</a></p>
<p style="margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">While the Walkthrough will take you briefly through the Entity Designer Enums experience, we want to make sure we show what is available. We&rsquo;d also like you to use this as a way to give direct feedback to the Entity Designer team on the user experience of working with Enums. We are already working on improvements to the experience shipped in the CTP, so please let us know what you think!</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<h2>Experience</h2>
<p class="MsoNormal">Similar to how Complex Types are represented in the Entity Designer, the primary location to work with Enums is via the Model Browser.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/7870.image001.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/7870.image001.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/7870.image001.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/7870.image001.jpg" width="306" height="452" /></a></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;There are two major points to note about using Enums in your Entity Data Model:</p>
<p style="text-indent: -0.25in;" class="MsoListParagraphCxSpFirst">1.<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Enum Types are not supported as shapes on the Entity Designer diagram surface</p>
<p style="text-indent: -0.25in;" class="MsoListParagraphCxSpMiddle">2.<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Enum Types are not created in your model via Database-First actions</p>
<p style="text-indent: -0.25in; margin-left: 1in;" class="MsoListParagraphCxSpMiddle">a.<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>When you create an EDM from an existing database, Enums are not defined in your model.</p>
<p style="text-indent: -0.25in; margin-left: 1in;" class="MsoListParagraphCxSpLast">b.<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Update Model from Database will preserve your declaration of Enum types, but again, will not detect Enum constructs from your database.</p>
<p class="MsoNormal">Please let us know your feedback on the importance of these items. For example, how valuable is it to you to be able to convert reference entity types imported from Database-First into enum types?</p>
<h5><b>Enum Type Dialog</b></h5>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/2768.image002.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/2768.image002.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/2768.image002.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/2768.image002.jpg" /></a></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><b>Name:</b> Name of Enum Type</p>
<p class="MsoNormal"><b>Underlying Type:</b> Valid underlying types for enum types are Int16, Int32, Int64, Byte, SByte.</p>
<p class="MsoNormal"><b>IsFlags:</b> When checked, denotes that this enum type is used as a bit field, and applies the Flags attribute to the definition of the Enum Type.</p>
<p class="MsoNormal"><b>Member Name and Value (optional):</b> Type or edit the members for the enum type and define optional values. Values must adhere to the underlying type of the enum.</p>
<p class="MsoNormal"><b>Errors:</b> Errors with your Enum Type definition will appear in the dialog in red, accompanied by a tooltip explaining what is invalid. Common errors are:</p>
<p style="text-indent: -0.25in;" class="MsoListParagraphCxSpFirst">-<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Not a valid enum member value: A Value entered that is invalid according to the underlying type</p>
<p style="text-indent: -0.25in;" class="MsoListParagraphCxSpMiddle">-<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Member is duplicated: Multiple Members entered with the same name</p>
<p style="text-indent: -0.25in;" class="MsoListParagraphCxSpLast">-<span style="font: 7pt/normal 'Times New Roman'; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Not a valid name for an enum member: A Member name entered with unsupported characters</p>
<p class="MsoNormal">Errors must be fixed before the Enum Type can be created or updated. We do have known issues with our error UI that we are fixing as I write! Feedback is more than welcome as to what is most helpful to you in the dialog.</p>
<h5><b>Entry Points</b></h5>
<p class="MsoNormal"><b>Create new Enum Type and Edit existing Enum Type:</b></p>
<p class="MsoListParagraphCxSpFirst"><i>Context Menu on Enum Types folder or existing Enum node in Model Browser</i></p>
<p class="MsoListParagraphCxSpLast">&nbsp;</p>
<p class="MsoListParagraphCxSpLast"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/2275.image003.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/2275.image003.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/2275.image003.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/2275.image003.jpg" width="372" height="418" /></a></p>
<p class="MsoNormal"><b>&nbsp;</b></p>
<p class="MsoNormal"><b>Convert Property to Enum:</b></p>
<p class="MsoListParagraphCxSpFirst"><i>Context menu on a Property in an Entity Type</i></p>
<p class="MsoListParagraphCxSpLast">&nbsp;</p>
<p class="MsoListParagraphCxSpLast"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/5342.image004.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/5342.image004.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/5342.image004.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/5342.image004.jpg" width="420" height="547" /></a></p>
<p class="MsoListParagraphCxSpLast">&nbsp;</p>
<p class="MsoNormal">Converting a property to an Enum type will create a new Enum Type. To use an existing Enum Type for a property, select the property and you will find existing Enum Types available in the Property Window in the Type drop down.</p>
<p class="MsoNormal"><b>Use existing Enum Type:</b></p>
<p style="text-indent: 0.5in; margin-bottom: 0pt;" class="MsoNormal"><i>Type in Property Window</i></p>
<p style="text-indent: 0.5in; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="text-indent: 0.5in; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/1050.image005.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/1050.image005.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/1050.image005.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/1050.image005.jpg" width="340" height="524" /></a></p>
<p style="text-indent: 0.5in; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h2>Feedback</h2>
<p style="margin-bottom: 0pt;" class="MsoNormal">As always, please let us know what is most valuable to you for using Enum Types in the Entity Designer. What would help you further about the existing support in CTP1? What would you need to see for Enum support in the Designer for it to be the most valuable to your development?</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">Feedback is always appreciated!</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">Thank you,</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">Sarah McDevitt</p>
<p style="margin-bottom: 0pt;" class="MsoNormal">Program Manager</p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Auto-Compiled LINQ Queries (Entity Framework June 2011 CTP)</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/auto-compiled-linq-queries-entity-framework-june-2011-ctp</link>
      <pubDate>Thu, 30 Jun 2011 00:22:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/06/30/auto-compiled-linq-queries-entity-framework-june-2011-ctp/</guid>
      <description><![CDATA[When you write a LINQ to Entities query today, the Entity Framework walks over the...]]></description>
      <content:encoded><![CDATA[<p><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 14" /><meta name="Originator" content="Microsoft Word 14" /><link rel="File-List" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Auto-Compiled%20Queries%20in%20EF%20June%202011%20CTP_files/filelist.xml" /> <link rel="Edit-Time-Data" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Auto-Compiled%20Queries%20in%20EF%20June%202011%20CTP_files/editdata.mso" /></p>
<p><link rel="themeData" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Auto-Compiled%20Queries%20in%20EF%20June%202011%20CTP_files/themedata.thmx" /> <link rel="colorSchemeMapping" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Auto-Compiled%20Queries%20in%20EF%20June%202011%20CTP_files/colorschememapping.xml" /></p>
<div class="WordSection1">
<p class="MsoNoSpacing">When you write a LINQ to Entities query today, the Entity Framework walks over the <i style="mso-bidi-font-style: normal;">expression tree</i> generated by the C#/VB compiler and translates (or compiles) that into SQL.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/8814.QueryTranslation.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/8814.QueryTranslation.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/8814.QueryTranslation.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/8814.QueryTranslation.jpg" width="632" height="106" /></a></o:p></p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">Compiling the expression tree into SQL involves some overhead though, particularly for more complex queries.<span style="mso-spacerun: yes;">&nbsp; </span>In order to avoid having to pay this performance penalty every time the LINQ query is executed, the <a href="https://msdn.microsoft.com/en-us/library/bb896297.aspx"><span class="SpellE">CompiledQuery</span></a> class was introduced.<span style="mso-spacerun: yes;">&nbsp; </span>This allows you to pay the overhead of compilation just once, and gives you back a delegate that points directly at the compiled version of the query in the Entity Framework cache.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span class="GramE"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">static</span></span><span style="font-family: Consolas; font-size: 9.5pt;"> <span class="SpellE"><span style="color: blue;">readonly</span></span> <span class="SpellE"><span style="color: #2b91af;">Func</span></span>&lt;<span class="SpellE"><span style="color: #2b91af;">NorthwindEntities</span></span>, <span class="SpellE"><span style="color: #2b91af;">IQueryable</span></span>&lt;<span style="color: blue;">string</span>&gt;&gt; query =<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span class="SpellE"><span style="color: #2b91af;">CompiledQuery</span>.Compile</span>&lt;<span class="SpellE"><span style="color: #2b91af;">NorthwindEntities</span></span>, <span class="SpellE"><span style="color: #2b91af;">IQueryable</span></span>&lt;<span style="color: blue;">string</span>&gt;<span class="GramE">&gt;(</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE">db</span></span> =&gt; <span style="color: blue;">from</span> c <span style="color: blue;">in</span> <span class="SpellE">db.Customers</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">where</span></span> <span class="SpellE">c.Country</span> == <span style="color: #a31515;">"USA"</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">select</span></span> <span class="SpellE">c.CompanyName</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNoSpacing">Each subsequent time you execute the query it&rsquo;s now much faster.</p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;"><o:p>&nbsp;</o:p></b></p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;">Auto-Compiled LINQ to Entities Queries<o:p></o:p></b></p>
<p class="MsoNoSpacing">The <a href="https://go.microsoft.com/fwlink/?LinkID=219445">Entity Framework June 2011 CTP</a> supports a new feature called Auto-Compiled LINQ Queries.<span style="mso-spacerun: yes;">&nbsp; </span>Now every LINQ to Entities query that you execute <b style="mso-bidi-font-weight: normal;">automatically </b>gets compiled and placed in EF&rsquo;s query cache.<span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>Each additional time you run the query, EF will find it in its query cache and won&rsquo;t have to go through the whole compilation process again.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">This also provides a boost to queries issued using <a href="https://msdn.microsoft.com/en-us/library/bb397951.aspx">WCF Data Services</a>, as it uses LINQ under the covers.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;">How <span class="GramE">Does</span> it Work?<o:p></o:p></b></p>
<p class="MsoNoSpacing">The Entity Framework will walk the nodes in the <a href="https://msdn.microsoft.com/en-us/library/bb397951.aspx">expression tree</a> and create a hash which becomes the key used to place it in the query cache.<span style="mso-spacerun: yes;">&nbsp; </span>If it does not find the query in the cache then it will go ahead and compile it and store the compiled query in the cache for subsequent use.<span style="mso-spacerun: yes;">&nbsp; </span>Each subsequent time, the hash will be calculated and find the compiled query in the tree, thus saving the compilation overhead.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;">Turning off Query Caching<o:p></o:p></b></p>
<p class="MsoNoSpacing">A new property on <span class="SpellE">ObjectContext.ContextOptions</span> has been introduced that allows you to control the default behavior of query compilation.<span style="mso-spacerun: yes;">&nbsp; </span>By default this property is true, but you can set it to false to disable auto-compilation of LINQ queries:</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span class="SpellE"><span style="font-family: Consolas; font-size: 9.5pt;">db.ContextOptions.DefaultQueryPlanCachingSetting</span></span><span style="font-family: Consolas; font-size: 9.5pt;"> = <span style="color: blue;">false</span>;<o:p></o:p></span></p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;">Note</b>: If you&rsquo;re using <span class="SpellE">DbContext</span> and need to get the <span class="SpellE">ObjectContext</span> instance, just cast to <span class="SpellE">IObjectContextAdapter</span>:</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">((<span style="color: #2b91af;">IObjectContextAdapter</span><span class="GramE">)db</span>).ObjectContext.ContextOptions.DefaultQueryPlanCachingSetting =</span> <span style="color: blue; font-family: Consolas; font-size: 9.5pt;">false</span><span style="color: black; mso-themecolor: text1;">;</span></p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">The value of this property gets propagated to the <a href="https://msdn.microsoft.com/en-us/library/system.data.objects.objectquery.enableplancaching.aspx"><span class="SpellE">EnablePlanCaching</span></a> property on each newly-created <span class="SpellE">ObjectQuery</span> for the <span class="SpellE">ObjectContext</span>.<span style="mso-spacerun: yes;">&nbsp; </span>Note: There is a known limitation in the June 2011 CTP: while <span class="SpellE">DefaultQueryPlanCachingSetting</span> is propagated to the <span class="SpellE">EnablePlanCaching</span> setting of each new query, the <span class="SpellE">EnablePlanCaching</span> setting is not propagated when using LINQ operators.<span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;">Performance Guidance<o:p></o:p></b></p>
<p class="MsoNoSpacing">Obviously when it comes to performance there&rsquo;s no one-size-fits-all approach.<span style="mso-spacerun: yes;">&nbsp; </span>The size/complexity of your application and queries will greatly influence how much of a performance boost your application will get from this.<span style="mso-spacerun: yes;">&nbsp; </span>It&rsquo;s important to measure your specific application with a good profiler.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">It is worth noting that using the <span class="SpellE">CompiledQuery</span> class is still the fastest approach, as the delegate that you get back does not need to calculate a hash of the expression tree.<span style="mso-spacerun: yes;">&nbsp; </span>Auto-compiled LINQ queries should be almost as fast though, and provide the benefit of not having to manually use the <span class="SpellE">CompiledQuery</span> class.</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNoSpacing"><b style="mso-bidi-font-weight: normal;">Feedback<o:p></o:p></b></p>
<p class="MsoNoSpacing">We&rsquo;d love to get your feedback on this feature and hear if it&rsquo;s helping in your application.<span style="mso-spacerun: yes;">&nbsp; </span>Please download the CTP today and let us know what you think!</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">Entity Framework Team</p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Enumeration Support in Entity Framework</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/enumeration-support-in-entity-framework</link>
      <pubDate>Wed, 29 Jun 2011 17:15:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/06/29/enumeration-support-in-entity-framework/</guid>
      <description><![CDATA[We recently shipped Entity Framework 4.1, and it has been exciting to see the reception the...]]></description>
      <content:encoded><![CDATA[<p><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 14" /><meta name="Originator" content="Microsoft Word 14" /><link rel="File-List" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Where%20are%20my%20Enums%20-%20blog%20post%20-%20v7_PK_files/filelist.xml" /> <link rel="Edit-Time-Data" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Where%20are%20my%20Enums%20-%20blog%20post%20-%20v7_PK_files/editdata.mso" /></p>
<p><link rel="dataStoreItem" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Where%20are%20my%20Enums%20-%20blog%20post%20-%20v7_PK_files/item0007.xml" target="Where%20are%20my%20Enums%20-%20blog%20post%20-%20v7_PK_files/props008.xml" /> <link rel="themeData" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Where%20are%20my%20Enums%20-%20blog%20post%20-%20v7_PK_files/themedata.thmx" /> <link rel="colorSchemeMapping" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Where%20are%20my%20Enums%20-%20blog%20post%20-%20v7_PK_files/colorschememapping.xml" /></p>
<p class="MsoNormal">We recently shipped <a href="https://blogs.msdn.com/b/adonet/archive/2011/04/11/ef-4-1-released.aspx">Entity Framework 4.1</a>, and it has been exciting to see the reception the new Code First and <span class="SpellE">DbContext</span> APIs have been getting in the developer community. What is also exciting is to be able to start talking more about other features we have been working on, like <a href="https://blogs.msdn.com/b/efdesign/archive/2011/01/21/table-valued-function-support.aspx">table-valued functions</a>, <a href="https://blogs.msdn.com/b/efdesign/archive/2011/03/09/unique-constraints-in-the-entity-framework.aspx">unique constraints</a> and <a href="https://blogs.msdn.com/b/efdesign/archive/2011/05/04/spatial-types-in-the-entity-framework.aspx">spatial types</a> support.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">At present, <span class="SpellE">enums</span> support is by far the most requested improvement for Entity Framework. We know it because we get asked about it each time we meet with a customer. We also see questions every week in the comments of <a href="https://blogs.msdn.com/b/efdesign/">our</a> <a href="https://blogs.msdn.com/b/adonet/">blogs</a>, in <a href="https://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/threads">our forums</a>, in tweets like <a href="https://twitter.com/paulstovell/statuses/76900341123252224">this</a>, and likewise in our own <a href="https://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions">feedback site</a>, in which <span class="SpellE">enums</span> currently has more than 1,600 votes. That is about 50% more votes than Code First!</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">After having had to explain <a href="https://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/9a5d5a64-4de8-4685-8896-c5e8f66fda65">several</a> <a href="https://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/7659feab-d348-4367-b2cd-0456b20262fe">times</a> why it takes so long for us to add <span class="SpellE">enums</span> support to EF, we are happy to say that we plan to do it in the next version after 4.1.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The goal of this blog post is to describe the design decisions we have made so far and to gather your feedback so that we can refine the design and calibrate the direction we have taken.</p>
<h1 class="WordSection1">Understanding <span class="SpellE">Enums</span> (and why they are so important)</h1>
<p class="MsoNormal">Unlike other things we get to work on, enumerations are an existing programming language feature. Our primary goal is to make sure the feature works as seamlessly as possible with the EF in Object/Relational Mapping scenarios.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">At the same time we have to focus on incorporating the concept of <span class="SpellE">enums</span> into the core of the metadata system underlying the EF, the Entity Data Model (EDM), in a manner that serves other key pieces of the EDM ecosystem, such as <a href="https://www.odata.org/"><span class="SpellE">OData</span></a> and <a href="https://msdn.microsoft.com/en-us/data/bb931106.aspx">WCF Data Services</a>.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">In order to achieve these goals we had to first recognize what <span class="SpellE">enums</span> are (and what they aren&rsquo;t) from the language design perspective, look at how they are commonly used within the realm of data oriented applications, understand requirement gaps, prioritize scenarios and come up with a design that can satisfy the most important among them.</p>
<p class="MsoNormal">&nbsp;</p>
<h2 class="WordSection1">A glimpse at enumeration support in the .NET programing languages</h2>
<p class="MsoNormal">The design of <span class="SpellE">enums</span> support in .NET programming languages like <a href="https://msdn.microsoft.com/en-us/library/cc138362.aspx">C#</a>, <a href="https://msdn.microsoft.com/en-us/library/8h84wky1(v=VS.100).aspx">VB</a> and <a href="https://msdn.microsoft.com/en-us/library/dd233216.aspx">F#</a> is amazingly simple. Yet from the perspective of modeling a specific domain, <span class="SpellE">enums</span> unquestionably provide great expressiveness.</p>
<p class="MsoNormal">This becomes apparent when looking at this straightforward example in C#:</p>
<p class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">enum</span></span> <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span></span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Express,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Priority,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Ground<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>[<span style="color: #2b91af;">Flags</span>]<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">enum</span></span> <span class="SpellE"><span style="color: #2b91af;">ContentType</span></span> : <span style="color: blue;">byte</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Liquid = 1,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Perishable = 2,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Edible = 4<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Package</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">int</span></span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">string</span> Description { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span></span> <span class="SpellE">ShippingMethod</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: #2b91af;">ContentType</span></span>? <span class="SpellE">ContentType</span> <span class="GramE">{ <span style="color: blue;">get</span></span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">string</span> Reference { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">Given this definition of Package, <span class="SpellE">ShippingMethod</span> and <span class="SpellE">ContentType</span>, the code necessary to change the <span class="SpellE">ShippingMethod</span> and <span class="SpellE">ContentType</span> of a package can be as simple as this:</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">juiceBox.ShippingMethod</span> = <span class="SpellE">ShippingMethod.Ground</span>;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">juiceBox.ContentType</span> = <span class="SpellE">ContentType.Liquid</span> | <span class="SpellE">ContentType.Perishable</span> | <span class="SpellE">ContentType.Edible</span>;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNoSpacing"><span style="font-family: Consolas; font-size: 9pt;"><o:p>&nbsp;</o:p></span></p>
<h3 class="WordSection1">Structural definition</h3>
<p class="MsoNormal">In C# <span class="SpellE">enums</span> can be structurally described like this:</p>
<div class="WordSection1">
<ul>
<li>
<div class="MsoNormal">The type declaration of an <span class="SpellE">enum</span> contains the name of the type and a list of zero or more named constants referred to as <span class="SpellE">enum</span> members</div>
</li>
<li>
<div class="MsoNormal">Each <span class="SpellE">enum</span> type also has an underlying type which is an non-<span class="SpellE">nullable</span> integral primitive type (Int32 if not specified in the declaration)</div>
</li>
<li>
<div class="MsoNormal">Each <span class="SpellE">enum</span> member consists of a member name and a member value</div>
</li>
<li>
<div class="MsoNormal">The set of values that an <span class="SpellE">enum</span> member can take is the valid range for the underlying type</div>
</li>
<li>
<div class="MsoNormal">The value of an <span class="SpellE">enum</span> member is optional in the type declaration.<span style="mso-spacerun: yes;">&nbsp; </span>If the value is not specified, it will be zero for the first member and one more than the value of the previous member for subsequent members</div>
</li>
<li>
<div class="MsoNormal">Multiple members with different names can have the same value</div>
</li>
<li>
<div class="MsoNormal">Member names are case sensitive and must be unique within the <span class="SpellE">enum</span> type declaration</div>
</li>
</ul>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Instances of <span class="SpellE">enum</span> types present specific characteristics:</p>
<ul>
<li>
<div class="MsoNormal">Any <span class="SpellE">enum</span> value can be explicitly casted to its underlying type</div>
</li>
<li>
<div class="MsoNormal">All possible values of an <span class="SpellE">enum</span> type can be obtained by casting any valid value of its underlying type to the <span class="SpellE">enum</span> type (i.e. valid <span class="SpellE">enum</span> values are not limited to the declared members of the <span class="SpellE">enum</span> type)</div>
</li>
<li>
<div class="MsoNormal">However, casting directly between two different <span class="SpellE">enum</span> types is not allowed</div>
</li>
<li>
<div class="MsoNormal">The default value for any <span class="SpellE">enum</span> type is always zero, casted to the <span class="SpellE">enum</span> type, even if there is no declared member in the <span class="SpellE">enum</span> type with a value of zero</div>
</li>
<li>
<div class="MsoNormal"><span class="SpellE">Enum</span> instances are equal-comparable and order-comparable against any other instance of the same <span class="SpellE">enum</span> type</div>
</li>
</ul>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The following comparisons are supported for <span class="SpellE">enums</span> in C#:</p>
<ul>
<li>
<div class="MsoNormal">Equality comparison between <span class="SpellE">enums</span>: ==<span class="GramE">, !=</span></div>
</li>
<li>
<div class="MsoNormal"><span class="GramE"></span>Order comparison between <span class="SpellE">enums</span>: &lt;, &gt;, &lt;=, &gt;=</div>
</li>
</ul>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The following operators are supported in C# and return an <span class="SpellE">enum</span> of the same type:</p>
<ul>
<li>
<div class="MsoNormal">Simple arithmetic between <span class="SpellE">enums</span> and the underlying type: +, -, ++, --, +=, -=</div>
</li>
<li>
<div class="MsoNormal">Bitwise operators between <span class="SpellE">enums</span> of the same type: ^, &amp;, |, ~</div>
</li>
</ul>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The definition of <span class="SpellE">enums</span> in VB is very similar to C#, although <span class="SpellE">enum</span> types in VB are required to have at least one member, and member names are case insensitive. Operator rules over <span class="SpellE">enums</span> are also different in VB: most arithmetic operators can be applied but the result of the operation will be of the underlying type instead of being an enumeration. In fact, only bitwise operations between two <span class="SpellE">enum</span> instances will result in another <span class="SpellE">enum</span> of the same type.</p>
<p class="MsoNormal">Independently of the language, the following library methods on <span class="SpellE">System.Enum</span> are particularly useful:</p>
<ul>
<li>
<div class="MsoNormal"><span class="SpellE"><b style="mso-bidi-font-weight: normal;">HasFlag</b></span>: Used to verify whether an instance of an <span class="SpellE">enum</span> type contains a specific value (see more on <span class="SpellE">enums</span> that can contain multiple values in the next section).</div>
</li>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Parse and <span class="SpellE">TryParse</span></b>: Converts a valid string representation to an <span class="SpellE">enum</span> instance.</div>
</li>
<li>
<div class="MsoNormal"><span class="SpellE"><b style="mso-bidi-font-weight: normal;">ToString</b></span>: Converts an instance of an <span class="SpellE">enum</span> to a string representation.</div>
</li>
</ul>
<h3>How <span class="SpellE">enums</span> are used in practice</h3>
<p class="MsoNormal">As simple as <span class="SpellE">enums</span> are, there is a lot of richness in how people think about them and how they are used in real world applications. At a high level, the common usages of <span class="SpellE">enums</span> are characterized by the following notions:</p>
<ul>
<li>
<div class="MsoNormal"><span class="SpellE"><b style="mso-bidi-font-weight: normal;">Enum</b></span><b style="mso-bidi-font-weight: normal;"> types in .NET allow grouping a set of named numeric constants associated to the same concepts into a type: </b></div>
</li>
<ul>
<li>
<div class="MsoNormal">Like regular constants, <span class="SpellE">enums</span> are a much more manageable alternative to sprinkling magic numbers across your code.</div>
</li>
<li>
<div class="MsoNormal">The ability to group sets of related constants and strong typing enable useful design-time services such as <span class="SpellE">Intellisense</span> and provide compile-time checks that help keep your code organized.</div>
</li>
</ul>
<li>
<div class="MsoNormal"><span class="SpellE"><b style="mso-bidi-font-weight: normal;">Enum</b></span><b style="mso-bidi-font-weight: normal;"> types in .NET always have an &ldquo;underlying&rdquo; integer type that determines the range of values that an instance can store:</b></div>
</li>
<ul>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;"></b>Fundamental aspects of using <span class="SpellE">enums</span>, such as the behavior of comparison, default values, arithmetic and bitwise operators depend on this underlying representation.</div>
</li>
<li>
<div class="MsoNormal">Although this correlation to integers is fundamental to the design, it is often possible to use <span class="SpellE">Enums</span> without paying much attention to it.</div>
</li>
<li>
<div class="MsoNormal">This is all consistent with the design of Enumerations in the <a href="https://msdn.microsoft.com/en-us/library/whbyts4t(v=VS.100).aspx">C language</a>, but in .NET <span class="SpellE">enums</span> are more type safe (e.g. you cannot assign directly a value of the underlying type to an <span class="SpellE">enum</span> variable without casting it explicitly).</div>
</li>
</ul>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;">In some cases, a variable of an <span class="SpellE">enum</span> type is used to simultaneously store a combination of multiple values:</b></div>
</li>
<ul>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;"></b>This is implemented by treating the underlying integer representation as a &ldquo;bit field&rdquo;.</div>
</li>
<li>
<div class="MsoNormal">In .NET, it is possible to express the intent of using an <span class="SpellE">enum</span> type in this way by adding the <span class="SpellE">FlagsAttribute</span> to the declaration of the type, and then by declaring each member to have an integer value that represents a different bit position:</div>
</li>
</ul>
</ul>
<p style="margin-left: 1in; mso-add-space: auto;" class="MsoListParagraphCxSpMiddle"><o:p>&nbsp;</o:p></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;</span>[<span style="color: #2b91af;">Flags</span>]<o:p></o:p></span></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">enum</span></span> <span class="SpellE"><span style="color: #2b91af;">ContentType</span></span> : <span style="color: blue;">byte</span><o:p></o:p></span></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Liquid = 1,<o:p></o:p></span></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Perishable = 2,<o:p></o:p></span></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Edible = 4<o:p></o:p></span></p>
<p style="text-indent: 0.25in; mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<ul>
<ul>
<li>
<div style="mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle">Enumerations that can represent multiple values simultaneously are a powerful concept, but the implementation in .NET is extremely simple: the programing languages handle all <span class="SpellE">enum</span> types in the same way, e.g. bitwise operators can be applied to <span class="SpellE">enums</span> regardless of the presence of <span class="SpellE">FlagsAttribute</span> (in fact, the attribute&rsquo;s sole impact in the behavior of the Base Class Library is in the conversion of an <span class="SpellE">enum</span> value to a string). In other words, there is no strong contract in using <span class="SpellE">FlagsAttribute</span>, and it is up to the developer to use only <span class="SpellE">enums</span> that were meant for multi-value in such a way.</div>
</li>
</ul>
<li>
<div style="mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle"><b style="mso-bidi-font-weight: normal;">Some tend to think of <span class="SpellE">enums</span> types as a way to model constrained categorizations, which assumes variables of an <span class="SpellE">enum</span> type can be guaranteed to only hold instances of its declared members: </b></div>
</li>
<ul>
<li>
<div style="mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle">Although <span class="SpellE">enums</span> are strongly typed in .NET, there is currently no way in .NET to express the intent to constrain the values to be only of the declared members. In fact, barring WCF serialization, nothing in .NET will constraint the value of an <span class="SpellE">enum</span> instance in this way.</div>
</li>
<li>
<div style="mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle">That said<span class="GramE">,</span> this is evidently a very useful thing to do, in particular in cases in which an <span class="SpellE">enum</span> is part of a public contract of a service, or in data centered applications, in which these constraints will often be backed by a database constraint.</div>
</li>
<li>
<div style="mso-layout-grid-align: none;" class="MsoListParagraphCxSpMiddle">Other languages outside of .NET, such as Java, deviate from the C design of <span class="SpellE">enums</span> based on integer underlying types to instead focus on constraining <span class="SpellE">enums</span> instances to only store declared values.</div>
</li>
</ul>
</ul>
<h2>Use of <span class="SpellE">enums</span> in data oriented applications</h2>
<p class="MsoNormal">Without native support for <span class="SpellE">enums</span> in the current version of Entity Framework, customers have come up with different ways to achieve similar functionality. The workarounds often require writing lots of additional code, and in the end, the experience is not as seamless as we would like it to be.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Incidentally, a common workaround, which consists of creating additional entity types for each of the types you would like to define as <span class="SpellE">enums</span>, can help illustrate the actual role of <span class="SpellE">enums</span> in data oriented applications.</p>
<p class="MsoNormal">Starting with the previous example, we would create additional entity types for <span class="SpellE">ShippingMethod</span> and <span class="SpellE">ContentType</span>, associating them to Package and then turning the <span class="SpellE">ShippingMethod</span> and <span class="SpellE">ContentTypes</span> properties into navigation properties:</p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Consolas; font-size: 9pt;"><o:p></o:p></span>&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">class</span> <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span></span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">int</span></span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">string</span> Name { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">class</span> <span class="SpellE"><span style="color: #2b91af;">ContentType</span></span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">int</span></span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">string</span> Name { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">virtual</span> <span class="SpellE"><span style="color: #2b91af;">ICollection</span></span>&lt;<span style="color: #2b91af;">Package</span>&gt; Packages { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Package</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">int</span></span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">virtual</span> <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span></span> <span class="SpellE">ShippingMethod</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">virtual</span> <span class="SpellE"><span style="color: #2b91af;">ICollection</span></span>&lt;<span class="SpellE"><span style="color: #2b91af;">ContentType</span></span>&gt; <span class="SpellE">ContentTypes</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Consolas; font-size: 9pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNoSpacing">Given this definition for Package, <span class="SpellE">ShippingMethod</span> and <span class="SpellE">ContentType</span>, the code for changing the <span class="SpellE">ShippingMethod</span> and <span class="SpellE">ContentType</span> of a package would be similar to this:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> ground = <span class="SpellE">context.ShippingMethods.Single</span>(c =&gt; <span class="SpellE">c.Name</span> == <span style="color: #a31515;">"Ground"</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> liquid = <span class="SpellE">context.ContentTypes.Single</span>(c =&gt; <span class="SpellE">c.Name</span> == <span style="color: #a31515;">"Liquid"</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> perishable = <span class="SpellE">context.ContentTypes.Single</span>(c =&gt; <span class="SpellE">c.Name</span> == <span style="color: #a31515;">"Perishable"</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> edible = <span class="SpellE">context.ContentTypes.Single</span>(c =&gt; <span class="SpellE">c.Name</span> == <span style="color: #a31515;">"Edible"</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">juice.ShippingMethod</span> = ground;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE">juice.ContentTypes.Clear</span></span><span class="GramE">(</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE">juice.ContentTypes.Add</span></span><span class="GramE">(</span>liquid);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE">juice.ContentTypes.Add</span></span><span class="GramE">(</span>perishable);<span style="mso-tab-count: 1;">&nbsp; </span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE">juice.ContentTypes.Add</span></span><span class="GramE">(</span>edible);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal">The solution based on entities is conceptually equivalent to one based on <span class="SpellE">enums</span>: in both cases, the list of all possible <span class="SpellE">ShippingMethods</span> and <span class="SpellE">ContentTypes</span> are used as <b style="mso-bidi-font-weight: normal;">&ldquo;reference data&rdquo;</b> for Package.</p>
<p class="MsoNormal">However, there are noticeable differences:</p>
<ul>
<li>
<div class="MsoNormal">Additional tables and foreign key constraints need to exist in the database and be mapped to the entities.</div>
</li>
<li>
<div class="MsoNormal">In order to establish an association, you need to first retrieve an instance of the related entity, e.g. by executing a query (this part can be made easier by adding an extra foreign key property to the entity, so you can establish an association by just assigning the value of the corresponding key to it, but the value of the key would likely become a magic number in your code).</div>
</li>
<li>
<div class="MsoNormal">Many-to-many associations are necessary to achieve similar results to &ldquo;flags&rdquo; <span class="SpellE">enums</span>, such as <span class="SpellE">Package.ContentTypes</span>. Many-to-many associations require twice as many tables and foreign key constraints in the database as regular one-to-many associations.</div>
</li>
<li>
<div class="MsoNormal">While instances of an entity type can have multiple properties, members of an <span class="SpellE">enum</span> type are in general constrained to only have a name and a value.</div>
</li>
<li>
<div class="MsoNormal">In general, an application will only be able to reason about <span class="SpellE">enum</span> members that existed at compile time. On the other hand, a solution based on entities can more easily evolve after the application has been written and compiled, because all the data exist in the database and can be modified at any time.</div>
</li>
</ul>
<p class="MsoListParagraphCxSpLast"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">In summary:</p>
<ul>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;">The main role of enumeration types in data oriented applications is to serve as simple lookup lists for reference data</b></div>
</li>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;"></b><span class="SpellE"><b style="mso-bidi-font-weight: normal;">Enums</b></span><b style="mso-bidi-font-weight: normal;"> require significantly less ceremony than using Entities </b></div>
</li>
<li>
<div class="MsoNormal"><b style="mso-bidi-font-weight: normal;"></b><b style="mso-bidi-font-weight: normal;">Because they are hardcoded and are constrained to only have names and values they are less broadly applicable<o:p></o:p></b></div>
</li>
</ul>
<h1><span class="SpellE">Enums</span> support in Entity Framework and Entity Data Model</h1>
<p class="MsoNormal">Taking into account the design of Enumerations in the .NET programing languages, the typical usage and the role of <span class="SpellE">Enums</span> in data oriented applications we explained above, we have decided to align the structural definition of <span class="SpellE">Enums</span> in the Entity Data Model with their definition in C#.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">This means that the declaration of <span class="SpellE">Enums</span> in EDM will have the same elements that they have in C#, including the optionally specified underlying type, case sensitive member names, optional values, etc., and that the same rules are used to choose values not specified, e.g. the default underlying type is also Int32 and the implicit value of members is the previous member plus one, starting with zero for the first member.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">This alignment in the design makes satisfying the requirements of O/RM scenarios for our customers much easier to use. It also enables all the richness of <span class="SpellE">enums</span> in the language, including such things as support for multi-valued (flags) <span class="SpellE">enums</span> in LINQ to Entities queries.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">When it comes to other consumers and producers of the EDM, like <span class="SpellE">OData</span>, the fact that other languages might have significantly different definitions of <span class="SpellE">enums</span> becomes relevant. In particular, Java 1.5 introduces first-class language support for the &ldquo;<span class="SpellE">typesafe</span> <span class="SpellE">enum</span> pattern&rdquo; previously used in Java programs to substitute missing support for <span class="SpellE">enums</span>. Java <span class="SpellE">enums</span> remove the idea of integral underlying types and instead implements <span class="SpellE">enums</span> that are completely constrained to the declared members.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">We recognize that there is a going to be a mismatch between the EDM semantics for <span class="SpellE">enums</span> and Java, but we believe the mismatch can be mitigated by the specific library implementations.</p>
<p class="MsoNormal">&nbsp;</p>
<h2>Requirements for <span class="SpellE">Enums</span> support in EF</h2>
<p class="MsoNormal">The following is an exhaustive list of the things that we believe developers using EF should be able to do with enumerations:</p>
<h3>Models, Metadata and Mapping</h3>
<p class="MsoNormal">Users creating an Entity Data Model should be able to define <span class="SpellE">enum</span> types (optionally specifying their underlying integer type) and their members (optionally specifying member values explicitly).</p>
<p class="MsoNormal">The following XML fragment is an example of how the definition of a simple <span class="SpellE">enum</span> type looks in <a href="https://msdn.microsoft.com/en-us/library/bb399292.aspx">CSDL</a>:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EnumType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span class="SpellE"><span style="color: blue;">ShippingMethod</span></span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Member</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Express</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Member</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Priority</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Member</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Ground</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;/</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EnumType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The corresponding <span class="SpellE">enum</span> type in C# looks like this:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">enum</span></span> <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span></span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Express,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Priority,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Ground<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Notice that the two type definitions above omit underlying type and member values. Since EDM will use the same rules for implicit underlying type and the assignment of unspecified member values as .NET programming languages, the two types above will unambiguously match, i.e. the underlying type for both is a 32 bit integer and the member values are 0, 1 and 2 for Express, Priority and Ground respectively.</p>
<p class="MsoNormal">&nbsp;</p>
<h4>Flags <span class="SpellE">enums</span></h4>
<p class="MsoNormal">When declaring an <span class="SpellE">enum</span> type in EDM, users should also be able to specify the intent to use this type as a &ldquo;flags&rdquo; <span class="SpellE">enums</span>:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EnumType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span class="SpellE"><span style="color: blue;">ContentType</span></span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">IsFlags</span></span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Member</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Liquid</span>"<span style="color: blue;"> </span><span style="color: red;">Value</span><span style="color: blue;">=</span>"<span style="color: blue;">1</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Member</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Perishable</span>"<span style="color: blue;"> </span><span style="color: red;">Value</span><span style="color: blue;">=</span>"<span style="color: blue;">2</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Member</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Edible</span>"<span style="color: blue;"> </span><span style="color: red;">Value</span><span style="color: blue;">=</span>"<span style="color: blue;">4</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;/</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EnumType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The only effect of this attribute in the <span class="SpellE">EnumType</span> element is to drive code generation to include the <span class="SpellE">FlagsAttribute</span> in the <span class="SpellE">enum</span> type definition. For instance, this is the equivalent code in C#:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>[<span style="color: #2b91af;">Flags</span>]<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">enum</span></span> <span class="SpellE"><span style="color: #2b91af;">ContentType</span></span> : <span style="color: blue;">byte</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Liquid = 1,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Perishable = 2,<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Edible = 4<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<h4><span class="SpellE">Nullable</span> <span class="SpellE">enums</span></h4>
<p class="MsoNormal">Once an <span class="SpellE">enum</span> type has been defined, it should be possible to declare <span class="SpellE">nullable</span> or non-<span class="SpellE">nullable</span> properties of this type in entities or complex types.</p>
<p class="MsoNormal">Example:</p>
<p class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EntityType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Package</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Key</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">PropertyRef</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Id</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Key</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Id</span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span class="SpellE"><span style="color: blue;">ShippingMethod</span></span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span class="SpellE"><span style="color: blue;">Model.ShippingMethod</span></span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span class="SpellE"><span style="color: blue;">ContentType</span></span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span class="SpellE"><span style="color: blue;">Model.ContentType</span></span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&hellip;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;/</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EntityType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<h4><span class="SpellE">Enums</span> as keys</h4>
<p class="MsoNormal">In addition, properties of <span class="SpellE">enum</span> types can participate <span style="line-height: 115%; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt;">in the definition of</span> primary keys, unique constraints and foreign keys, as well as take part in concurrency control checks, and have declared default values.</p>
<p class="MsoNormal">&nbsp;</p>
<h4>Mapping</h4>
<p class="MsoNormal">Properties of <span class="SpellE">enum</span> types support all the same mapping scenarios as properties of the underlying type:</p>
<ul>
<li>
<div class="MsoNormal">An <span class="SpellE">enum</span> property in EDM can be mapped to any of the store integral types supported by EF: Byte, Int16, Int32 and Int64</div>
</li>
<li>
<div class="MsoNormal">Entities with <span class="SpellE">enum</span> properties can be mapped using stored procedures and query views</div>
</li>
<li>
<div class="MsoNormal">For object to conceptual mapping, both attribute-based (most commonly used in <span class="SpellE">EntityObject</span> code generated entities) and convention (most commonly used for POCO types) based mapping are available.</div>
</li>
</ul>
<p class="MsoListParagraphCxSpLast"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><strong>Note</strong>: We expect that customers will use <span class="SpellE">enums</span> in many cases in which previously they would have used entities with reference data. Unlike entities, <span class="SpellE">enum</span> types are not mapped to tables in the database. Users are free to have tables and foreign key constraints, or check constraints in the database that enforce <span class="SpellE">enum</span> values. However Entity Framework will not reason about these constraints at runtime, so it is up to the user to keep rows in those tables and <span class="SpellE">enum</span> members in sync.</p>
<p class="MsoNormal">&nbsp;</p>
<h4>New metadata APIs</h4>
<p class="MsoNormal">The metadata API has been updated to be able to reason about <span class="SpellE">enum</span> types. The following classes, <span class="SpellE">EnumType</span> and <span class="SpellE">EnumMember</span> are used to represent <span class="SpellE">enums</span> in the EDM layer:</p>
<ul>
<ul>
<li>
<div class="MsoNormal"><span class="SpellE">System.Data.Metadata.Edm.EnumType</span> class represents an <span class="SpellE">enum</span> type</div>
</li>
<li>
<div class="MsoNormal"><span class="SpellE">System.Data.Metadata.Edm.EnumMember</span> class represents an <span class="SpellE">enum</span> member</div>
</li>
<li>
<div class="MsoNormal">New overloads of <span class="SpellE"><span class="GramE">MetadataWorkspace.GetObjectSpaceType</span></span><span class="GramE">(</span>), <span class="SpellE">MetadataWorkspace.GetEdmSpaceType</span>() and <span class="SpellE">ObjectItemCollection.GetClrType</span>() have been added that allow navigating the mapping between <span class="SpellE">enums</span> the EDM layer and the object layer.</div>
</li>
</ul>
</ul>
<div class="MsoNormal">&nbsp;</div>
<h4>Code First APIs</h4>
<p class="MsoNormal">Code First&rsquo;s property mapping fluent APIs have been extended to support <span class="SpellE">enum</span> types.</p>
<p class="MsoNormal">Example:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">class</span> <span class="SpellE"><span style="color: #2b91af;">ShippingContext</span></span> : <span class="SpellE">DbContext</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE">DbSet</span>&lt;<span style="color: #2b91af;">Package</span>&gt; Packages { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">protected</span></span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> <span class="SpellE">OnModelCreating</span>(<span class="SpellE">DbModelBuilder</span> <span class="SpellE">modelBuilder</span>)<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE">modelBuilder.Entity</span>&lt;<span style="color: #2b91af;">Package</span><span class="GramE">&gt;(</span>).Property(p =&gt; <span class="SpellE">p.ShippingMethod</span>).<span class="SpellE">HasColumnName</span>(<span style="color: #a31515;">"<span class="SpellE">sm</span>"</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<h3>Query</h3>
<p class="MsoNormal">All types of Entity Framework queries (including <span class="SpellE">EntityClient</span> queries and object layer queries written in LINQ or Entity SQL) can refer to <span class="SpellE">enums</span>. For instance, the following operations are allowed:</p>
<ul>
<li>
<div class="MsoNormal">Projection of <span class="SpellE">enum</span> properties, constants and parameters</div>
</li>
<li>
<div class="MsoNormal">Use of <span class="SpellE">enum</span> properties, constants and parameters in filtering predicates</div>
</li>
<li>
<div class="MsoNormal">Use of <span class="SpellE">enums</span> as parameters and in the return type of Functions</div>
</li>
<li>
<div class="MsoNormal">Use of <span class="SpellE">enums</span> as parameters and in the return type of pass-through SQL APIs such as <span class="SpellE">ExecuteStoreQuery</span>, <span class="SpellE">ExecuteStoreCommand</span>, <span class="SpellE">SqlQuery</span>, etc.</div>
</li>
<li>
<div class="MsoNormal">Cast explicitly between <span class="SpellE">enum</span> instances and the underlying type of the <span class="SpellE">enum</span> (or types that support explicit cast from underlying type of the <span class="SpellE">enum</span>) in queries</div>
</li>
<li>
<div class="MsoNormal">Use of equality and order comparisons: ==<span class="GramE">, !</span>=, &lt;, &gt;, &lt;=, &gt;=</div>
</li>
<li>
<div class="MsoNormal">Use of arithmetic and bitwise operators in LINQ queries: +, -, ^, &amp;, |, ~ (the exact behavior and result type depends on the .NET language being used)</div>
</li>
</ul>
<p class="MsoListParagraphCxSpLast"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><strong>Note</strong>: Increment and decrement operators such as ++, --, += and -= have side effects and therefore cannot be supported in queries.</p>
<p class="MsoNormal">Example:</p>
<p class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> <span class="SpellE">groundPackages</span> =<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">from</span></span> p <span style="color: blue;">in</span> <span class="SpellE">context.Packages</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">where</span></span> <span class="SpellE">p.ShippingMethod</span> == <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span>.Ground</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">select</span></span> p;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<h3>Update</h3>
<p class="MsoNoSpacing">Entity Framework entities and complex types that contain <span class="SpellE">enum</span> properties can be inserted, updated and deleted. In addition, <span class="SpellE">enum</span> properties can be store generated and used for concurrency control.</p>
<p class="MsoNoSpacing"><o:p>&nbsp;</o:p></p>
<p class="MsoNoSpacing">Example:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> <span class="SpellE">juiceBox</span> = <span class="SpellE">context.Packages.Where</span>(p =&gt; <span class="SpellE">p.Name</span> == <span style="color: #a31515;">"Juice box"</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE">juiceBox.ShippingMethod</span> = <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span>.Ground</span>;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE">juiceBox.ContentType</span> = <span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Liquid</span> | <span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Perishable</span> | <span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Edible</span>;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE">context.SaveChanges</span></span><span class="GramE">(</span>);<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<h3>Designer support</h3>
<p class="MsoNormal">The Entity Designer has been extended to support the definition of <span class="SpellE">enum</span> types. An upcoming blog post will contain more details about designer support.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong>Note</strong>: Reverse engineering a database into a model (usually called &ldquo;database first&rdquo;) never introduces <span class="SpellE">enums</span> into the model automatically. Users need to manually specify which properties represent <span class="SpellE">enum</span> types.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Code generation</h3>
<p class="MsoNormal">Code <span class="GramE">generation,</span> including EdmGen.exe, <span class="SpellE">EntityObject</span> template, Self-Tracking Entities template and <span class="SpellE">DbContext</span> template have been updated to generate <span class="SpellE">enum</span> type definitions and properties of <span class="SpellE">enum</span> types.</p>
<p class="MsoNormal">&nbsp;</p>
<h1>Limitations</h1>
<p class="MsoNormal">There are several features we considered that will not be included in the upcoming release of EF:</p>
<h3><span class="SpellE"><span class="GramE">ToString</span></span><span class="GramE">(</span>) and Parse()/<span class="SpellE">TryParse</span>() won&rsquo;t be supported in queries</h3>
<p class="MsoNormal">Translation into store queries would require very complex expressions to achieve fidelity with the behavior of these methods in the CLR.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Mapping <span class="SpellE">Enums</span> to strings and arbitrary types</h3>
<p class="MsoNormal">We consider the general ability to perform property type transformations in the mapping to be an important feature, but it wasn&rsquo;t a priority this time around. Barring type transformations the most natural thing to do for <span class="SpellE">enums</span> is to support mapping to integer numeric types.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Using <span class="SpellE">enum</span> properties as mapping discriminators is not supported</h3>
<p class="MsoNormal">The Entity Framework runtime supports the use of Boolean properties as mapping discriminators, i.e. the value of the property in an entity is used to decide in what table in the store that entity instance should <span class="SpellE">stored</span>. We could consider adding the same capability for <span class="SpellE">enum</span> properties, but this wasn&rsquo;t a priority in this release.</p>
<p class="MsoNormal">&nbsp;</p>
<h1>Feedback requested</h1>
<p class="MsoNormal">As always, your opinions on all aspects of this design are welcome. However, there are specific areas in which we are seeking your help in deciding where to take the design. Please, take some time to answer them in the comments.</p>
<h3>Checked or Strict <span class="SpellE">enums</span></h3>
<p class="MsoNormal">As we explained before, constraining the value of an <span class="SpellE">enum</span> to the declared members is one of the common notions of <span class="SpellE"><span class="GramE">enums</span></span><span class="GramE">,</span> however in .NET we don&rsquo;t provide a way to express this intent. One thing we could consider doing is to enable this in EF:</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">When declaring an <span class="SpellE">enum</span> property, users should also be able to declare the intent to constrain the values of the property. They could do this using adding a new &ldquo;Checked&rdquo; facet to properties.</p>
<p class="MsoNormal">Example:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EntityType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Package</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Key</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">PropertyRef</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Id</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Key</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Id</span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span class="SpellE"><span style="color: blue;">ShippingMethod</span></span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span class="SpellE"><span style="color: blue;">Model.ShippingMethod</span></span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> </span><span style="color: red;">Checked</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">Name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span class="SpellE"><span style="color: blue;">ContentType</span></span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span class="SpellE"><span style="color: blue;">Model.ContentType</span></span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;"> </span><span style="color: red;">Checked</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&hellip;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&lt;/</span><span class="SpellE"><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">EntityType</span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The only practical effect of the <span class="GramE">Checked</span> attribute in the Property element of an <span class="SpellE">enum</span> type would be to enable the <span class="SpellE">DbContext</span> API to perform data validation in the property. <span class="SpellE">DbContext</span> performs data validation automatically by default on <span class="SpellE">SaveChanges</span> and can also perform it on demand. For an <span class="SpellE">enum</span> property that has this attribute, if the property value does not correspond to a declared member (or to a valid combination if the <span class="SpellE">enum</span> type is &ldquo;flags&rdquo;) validation will fail and <span class="SpellE">SaveChanges</span> will abort.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The equivalent behavior could be obtained when using Code First by adding a new validation data annotation or using a fluent API.</p>
<p class="MsoNormal">Example:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Package</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: blue;">int</span></span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">string</span> Description { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[Checked]<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: #2b91af;">ShippingMethod</span></span> <span class="SpellE">ShippingMethod</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[Checked]<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span class="SpellE"><span style="color: #2b91af;">ContentType</span></span>? <span class="SpellE">ContentType</span> <span class="GramE">{ <span style="color: blue;">get</span></span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">public</span></span> <span style="color: blue;">string</span> Reference { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><strong>Note</strong>: The data validation feature in <span class="SpellE">DbContext</span> is explained in more details <a href="https://blogs.msdn.com/b/adonet/archive/2011/05/27/ef-4-1-validation.aspx">here</a> and <a href="https://blogs.msdn.com/b/adonet/archive/2010/12/15/ef-feature-ctp5-validation.aspx">here</a>.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Question: </b>How important is it to validate <span class="SpellE">enum</span> values in this way for you? Would you give up any of the other features explained in this post for it?<b style="mso-bidi-font-weight: normal;"> <o:p></o:p></b></p>
<h3><span class="SpellE">HasFlag</span> support</h3>
<p class="MsoNormal">.NET 4.0 introduced this new method in <span class="SpellE">System.Enum</span> that makes it possible to detect whether an instance of a &ldquo;flags&rdquo; <span class="SpellE">enum</span> contains a value without having to resort to or think about bitwise operators. We could consider adding support for this method on LINQ to Entities.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Example:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> <span class="SpellE">perishableLiquids</span> =<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">from</span></span> p <span style="color: blue;">in</span> <span class="SpellE">context.Packages</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">where</span></span> <span class="SpellE">p.ContentType.HasFlag</span>(<span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Perishable</span> | <span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Liquid</span>)<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">select</span></span> p;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">This is equivalent to:</p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span class="GramE"><span style="color: blue;">var</span></span></span> <span class="SpellE">perishableLiquids</span> =<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">from</span></span> p <span style="color: blue;">in</span> <span class="SpellE">context.Packages</span><o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">where</span></span> <span class="SpellE">p.ContentType</span> &amp; (<span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Perishable</span> | <span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Liquid</span>) ==<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(<span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Perishable</span> | <span class="SpellE"><span style="color: #2b91af;">ContentType</span>.Liquid</span>)<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="GramE"><span style="color: blue;">select</span></span> p;<o:p></o:p></span></p>
<p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;" class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Question:</b> How important is it to be able to use <span class="SpellE">HasFlag</span> in LINQ queries for you? Would you give up any of the other features explained in this post for it?</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Options to disable code generation for specific types</h3>
<p class="MsoNormal"><span class="SpellE">Enum</span> types are primarily a code construct and therefore their existence is commonly independent of an EF model. If you try to use an <span class="SpellE">enum</span> type that is already declared with your code-generated entities it can become very difficult because EF code generation will always generate a new <span class="SpellE">enum</span> type for the type defined in the EDM model.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">We could consider improving this by defining an annotation that you could easily put on specific types (<span class="SpellE">enum</span>, entity or complex type) in your model that would signal EF code generation templates to ignore that type.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Question: </b>How important is it to you to be able to skip generating specific types from your model? Would you give up any of the other features explained in this post for it?</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Diego Vega<br /> Program Manager<br /> Entity Framework Team<b style="mso-bidi-font-weight: normal;"><o:p></o:p></b></p>]]></content:encoded>
    </item>
    <item>
      <title>Spatial Types in the Entity Designer</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/spatial-types-in-the-entity-designer</link>
      <pubDate>Thu, 12 May 2011 10:22:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/05/12/spatial-types-in-the-entity-designer/</guid>
      <description><![CDATA[One of the highly-anticipated features coming in the next version of Entity Framework is Spatial...]]></description>
      <content:encoded><![CDATA[<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/2477.image001.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/2477.image001.png"></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/0550.image002.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/0550.image002.jpg"></a>One of the highly-anticipated features coming in the next version of Entity Framework is Spatial support. We&rsquo;d like to give you a look at the experience of developing with Spatial types in the Entity Designer. If you haven&rsquo;t already, take a look at what is going on under the hood with Spatial types in the Entity Framework in the blog post <a href="https://blogs.msdn.com/b/efdesign/archive/2011/05/04/spatial-types-in-the-entity-framework.aspx">here</a>.&nbsp;</p>
<p>We&rsquo;d like to show you what is coming your way for Spatial types in the Entity Designer and of course, let us know what you think and give us feedback on the experience!</p>
<p><b>Goals</b> </p>
<p>The goals for supporting Spatial types in the Entity Designer align with Entity Framework design goals for Spatial as well:</p>
<ul>
<li>First class support for Spatial types in the Entity Designer</li>
<li>Model-first and Database-first support through the Entity Designer</li>
</ul>
<p><b>Spatial Types</b></p>
<ul>
<li>Geometry</li>
<li>Geography</li>
</ul>
<p><b>Experience</b></p>
<p>Since the Entity Framework adds Spatial types as primitive EDM types, we treat them exactly as you are used to using primitive types in the Entity Designer. </p>
<ol>
<li>Add Property to Entity Type </li>
<li>Set Data Type as Geography through the Property Window</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/5040.image002.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/5040.image002.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/5040.image002.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/5040.image002.jpg" border="0" /></a></p>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/4532.image004.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/4532.image004.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/4532.image004.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/4532.image004.png" border="0" /></a></p>
<p>&nbsp;</p>
<p><b>Restrictions</b></p>
<p>Spatial types cannot be used as entity keys, in associations, or as discriminators. We give design-time validation errors if you attempt to use one of those invalid patterns.</p>
<p>&nbsp;</p>
<ol>
<li>Attempt to set property of type Geometry as entity key</li>
<li>Validation error in Error List</li>
</ol>
<p>&nbsp;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/6102.image006.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/6102.image006.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/6102.image006.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/6102.image006.png" border="0" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/7776.image003.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-06-61/7776.image003.png"></a></p>
<p>&nbsp;</p>
<p><b>Feedback</b></p>
<p>As always, please let us know what is most valuable to you in the Entity Designer for using Spatial data types. Feedback is always appreciated!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Thank you,</p>
<p>Sarah McDevitt</p>
<p>Program Manager</p>]]></content:encoded>
    </item>
    <item>
      <title>Spatial Types in the Entity Framework</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/spatial-types-in-the-entity-framework</link>
      <pubDate>Wed, 04 May 2011 14:37:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/05/04/spatial-types-in-the-entity-framework/</guid>
      <description><![CDATA[Pedro Ardila
  Normal
  Pedro Ardila
  2
  5
  2011-05-04T21:47:00Z...]]></description>
      <content:encoded><![CDATA[<p>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 14" name="Generator" />
<meta content="Microsoft Word 14" name="Originator" />
<link href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Spatial%20types%20in%20the%20Entity%20Framework_files/filelist.xml" rel="File-List" />
</p>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Pedro Ardila</o:Author>
  <o:Template>Normal</o:Template>
  <o:LastAuthor>Pedro Ardila</o:LastAuthor>
  <o:Revision>2</o:Revision>
  <o:TotalTime>5</o:TotalTime>
  <o:Created>2011-05-04T21:47:00Z</o:Created>
  <o:LastSaved>2011-05-04T21:47:00Z</o:LastSaved>
  <o:Pages>2</o:Pages>
  <o:Words>1238</o:Words>
  <o:Characters>7060</o:Characters>
  <o:Company>Microsoft Corporation</o:Company>
  <o:Lines>58</o:Lines>
  <o:Paragraphs>16</o:Paragraphs>
  <o:CharactersWithSpaces>8282</o:CharactersWithSpaces>
  <o:Version>14.00</o:Version>
 </o:DocumentProperties>
 <o:OfficeDocumentSettings>
  <o:AllowPNG />
 </o:OfficeDocumentSettings>
</xml><![endif]-->
<p>
<link target="Spatial%20types%20in%20the%20Entity%20Framework_files/props009.xml" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Spatial%20types%20in%20the%20Entity%20Framework_files/item0008.xml" rel="dataStoreItem" />
<link target="Spatial%20types%20in%20the%20Entity%20Framework_files/props011.xml" href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Spatial%20types%20in%20the%20Entity%20Framework_files/item0010.xml" rel="dataStoreItem" />
<link href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Spatial%20types%20in%20the%20Entity%20Framework_files/themedata.thmx" rel="themeData" />
<link href="https://blogs.msdn.com/controlpanel/blogs/posteditor.aspx/Spatial%20types%20in%20the%20Entity%20Framework_files/colorschememapping.xml" rel="colorSchemeMapping" />
</p>
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:TrackMoves>false</w:TrackMoves>
  <w:TrackFormatting />
  <w:PunctuationKerning />
  <w:ValidateAgainstSchemas />
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF />
  <w:LidThemeOther>EN-US</w:LidThemeOther>
  <w:LidThemeAsian>X-NONE</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables />
   <w:SnapToGridInCell />
   <w:WrapTextWithPunct />
   <w:UseAsianBreakRules />
   <w:DontGrowAutofit />
   <w:SplitPgBreakAndParaMark />
   <w:EnableOpenTypeKerning />
   <w:DontFlipMirrorIndents />
   <w:OverrideTableStyleHps />
   <w:UseFELayout />
  </w:Compatibility>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math" />
   <m:brkBin m:val="before" />
   <m:brkBinSub m:val="&#45;-" />
   <m:smallFrac m:val="off" />
   <m:dispDef />
   <m:lMargin m:val="0" />
   <m:rMargin m:val="0" />
   <m:defJc m:val="centerGroup" />
   <m:wrapIndent m:val="1440" />
   <m:intLim m:val="subSup" />
   <m:naryLim m:val="undOvr" />
  </m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267">
  <w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal" />
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" />
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" />
  <w:LsdException Locked="false" Priority="39" Name="toc 1" />
  <w:LsdException Locked="false" Priority="39" Name="toc 2" />
  <w:LsdException Locked="false" Priority="39" Name="toc 3" />
  <w:LsdException Locked="false" Priority="39" Name="toc 4" />
  <w:LsdException Locked="false" Priority="39" Name="toc 5" />
  <w:LsdException Locked="false" Priority="39" Name="toc 6" />
  <w:LsdException Locked="false" Priority="39" Name="toc 7" />
  <w:LsdException Locked="false" Priority="39" Name="toc 8" />
  <w:LsdException Locked="false" Priority="39" Name="toc 9" />
  <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" />
  <w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title" />
  <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" />
  <w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle" />
  <w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong" />
  <w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis" />
  <w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid" />
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" />
  <w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1" />
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" />
  <w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" />
  <w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote" />
  <w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5" />
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6" />
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6" />
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6" />
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" />
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" />
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6" />
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6" />
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" />
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" />
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" />
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6" />
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6" />
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6" />
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6" />
  <w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" />
  <w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" />
  <w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" />
  <w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" />
  <w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title" />
  <w:LsdException Locked="false" Priority="37" Name="Bibliography" />
  <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" />
 </w:LatentStyles>
</xml><![endif]-->

<!--[if gte mso 10]>
<mce:style><! 
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin-top:0in;
	mso-para-margin-right:0in;
	mso-para-margin-bottom:10.0pt;
	mso-para-margin-left:0in;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:minor-bidi;}
table.Table
	{mso-style-name:Table;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-unhide:no;
	border:solid #A5A5A5 1.0pt;
	mso-border-alt:solid #A5A5A5 .5pt;
	mso-padding-alt:2.15pt 5.75pt 2.15pt 5.75pt;
	mso-border-insideh:.5pt solid #A5A5A5;
	mso-border-insidev:.5pt solid #A5A5A5;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Verdana","sans-serif";
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";}
table.TableFirstRow
	{mso-style-name:Table;
	mso-table-condition:first-row;
	mso-style-unhide:no;
	mso-tstyle-shading:#5C83B4;
	color:white;
	mso-ansi-font-weight:bold;}
-->
<!--[endif] --><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">One of the highly-anticipated features coming in the next
version of Entity Framework is <span class="GramE">Spatial</span> support. The
team has been hard at work designing a compelling story for Spatial, and we
would love to get your feedback on it. In this post we will cover:</p>
<ul>
<li>The basics of SQL Server&rsquo;s<span style="mso-spacerun: yes;">&nbsp; </span>spatial support</li>
<li>Design goals</li>
<li>Walkthrough of design: CLR types, Metadata, Usage,
WCF Serialization, Limitations</li>
<li>Questions (we want to hear from you!)</li>
</ul>
<p class="MsoNormal">This entry will not cover the tools experience as we want to
focus on what is happening under the hood.<span style="mso-spacerun: yes;">&nbsp;
</span>We will blog about the tools design at a later time. For now, be sure
that we plan on shipping Spatial with Tools support.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: 13.0pt; mso-bidi-font-size: 11.0pt; line-height: 115%;">The Basics
of Spatial<br />
</span></b>For those of you that are new to Spatial, let&rsquo;s briefly describe
what it&rsquo;s all about: There are two basic spatial types called Geometry and
Geography which allow you to perform geospatial calculations. An example of a
geospatial calculation is figuring out the distance between Seattle and New
York, or calculating the size (i.e. area) of a state, where the state has been
described as a polygon.</p>
<p class="MsoNormal">Geometry and Geography are a bit different. <b style="mso-bidi-font-weight: normal;">Geometry</b> deals with planar data.
Geometry is well documented under the <a href="https://www.opengeospatial.org/standards/sfa">Open Geospatial Consortium
(OGC) Specification</a>. <b style="mso-bidi-font-weight: normal;">Geography</b>
deals with ellipsoidal data, taking in mind the curvature of the earth when
performing any calculations. SQL introduced spatial support for these two types
in SQL Server 2008. The SQL implementation supports all of the standard
functions outlined in the OGC spec.</p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><o:p>&nbsp;</o:p></b></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Programming Experience
in SQL<br />
</b>The query below returns all the stores within half a mile of the address of
a person whose ID is equal to 2. In the where clause we multiply the result of <span class="SpellE">STDistance</span> by 0.00062 to convert meters to miles.<b style="mso-bidi-font-weight: normal;"><o:p></o:p></b></p>
<div style="mso-element: para-border-div; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242;">
<p style="margin-top: 2.9pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">DECLARE </span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">@<span class="SpellE">dist</span> </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: green; mso-font-kerning: 12.0pt;">sys</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">geography</span></span><span style="font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="margin-top: 2.9pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">SET </span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">@<span class="SpellE">dist</span> </span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">=</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">(</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">SELECT </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">p</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">Address</span></span><span style="font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="margin-top: 2.9pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp; </span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">FROM </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">dbo</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">People</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">as</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> p</span><span style="font-size: 9.5pt;"><o:p></o:p></span></p>
<p style="margin-top: 2.9pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp; </span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">WHERE </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">p</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">PersonID</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">=</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> 2</span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">)<o:p></o:p></span></p>
<p style="margin-top: 2.9pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p style="margin: 0in; margin-bottom: .0001pt; line-height: 120%; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">SELECT</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> [Store]</span><span class="GramE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">[</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">Name]</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">,</span><span style="font-size: 9.5pt; line-height: 120%;"><o:p></o:p></span></p>
<p style="margin: 0in; margin-bottom: .0001pt; line-height: 120%; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[Store]</span><span class="GramE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">[</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">Location]</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span class="SpellE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">Lat</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">,</span><span style="font-size: 9.5pt; line-height: 120%;"><o:p></o:p></span></p>
<p style="margin: 0in; margin-bottom: .0001pt; line-height: 120%; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>[Store]</span><span class="GramE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">[</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">Location]</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">Long</span><span style="font-size: 9.5pt; line-height: 120%;"><o:p></o:p></span></p>
<p style="margin: 0in; margin-bottom: .0001pt; line-height: 120%; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">FROM</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>[<span class="SpellE">dbo</span>]</span><span class="GramE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">[</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">Stores] </span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">AS</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> [Store]</span><span style="font-size: 9.5pt; line-height: 120%;"><o:p></o:p></span></p>
<p style="margin: 0in; margin-bottom: .0001pt; line-height: 120%; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;"><span class="GramE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">WHERE<span style="mso-spacerun: yes;">&nbsp; </span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">(</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">(</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">[Store]</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">[Location]</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">.</span><span class="SpellE"><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">STDistance</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">(</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">@<span class="SpellE">dist</span></span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">))</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">*</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: fuchsia; mso-font-kerning: 12.0pt;">cast</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">(</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">0.00062 </span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">as</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: blue; mso-font-kerning: 12.0pt;">float</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">(</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;">53</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">)))</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> </span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: gray; mso-font-kerning: 12.0pt;">&lt;=</span><span style="font-size: 9.5pt; line-height: 120%; font-family: Consolas; mso-fareast-font-family: +mn-ea; color: black; mso-font-kerning: 12.0pt;"> .5<o:p></o:p></span></p>
</div>
<p style="margin-top: 12.0pt;" class="MsoNormal">In the sample below, we change the
person&rsquo;s address to a different coordinate. Note that <span class="SpellE">STGeomFromText</span>
takes two parameters: the point, and a Spatial Reference Identifier (SRID). <span class="GramE">The value of 4326 maps to the WGS 84 which is the standard
coordinate system for the Earth.</span> </p>
<div style="mso-element: para-border-div; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: 'Courier New'; color: blue; mso-no-proof: yes;">update</span><span style="font-size: 9.5pt; font-family: 'Courier New'; mso-no-proof: yes;"> [dbo]<span style="color: gray;">.</span>[People]<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: 'Courier New'; color: blue; mso-no-proof: yes;">set</span><span style="font-size: 9.5pt; font-family: 'Courier New'; mso-no-proof: yes;"> [Address] <span style="color: gray;">=</span> <span style="color: blue;">geography</span><span style="color: gray;">::</span>STGeomFromText<span style="color: gray;">(</span><span style="color: red;">'POINT(-122.206834 57.611421)'</span><span style="color: gray;">,</span>
4326<span style="color: gray;">)<o:p></o:p></span></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: 'Courier New'; color: blue; mso-no-proof: yes;">where</span><span style="font-size: 9.5pt; font-family: 'Courier New'; mso-no-proof: yes;"> [PersonID] <span style="color: gray;">=</span> 2<o:p></o:p></span></p>
</div>
<p class="MsoNormal">Note that when listing a point, the longitude is listed
before the latitude.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: 13.0pt; mso-bidi-font-size: 11.0pt; line-height: 115%;">Design<o:p></o:p></span></b></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Goals</b><br />
The goals for spatial are the following:</p>
<ul>
<li>To provide a first class support for spatial in
EDM</li>
<li>Rich Programming experience in LINQ and Entity
SQL against Spatial types</li>
<li>Code-first, Model-first, and Database-first
support</li>
<li>Tooling (not covered in this blog)</li>
</ul>
<p class="MsoNormal">We have introduced two new primitive EDM Types called <b style="mso-bidi-font-weight: normal;">Geometry</b> and <b style="mso-bidi-font-weight: normal;">Geography</b>. This allows us to have spatial-typed properties in our
Entities and Complex Types. As with every other primitive type in EDM, Geometry
and Geography will be associated with CLR types. In this case, we have created
two new types named <span class="SpellE"><b style="mso-bidi-font-weight: normal;">DBGeometry</b></span>
and <span class="SpellE"><b style="mso-bidi-font-weight: normal;">DBGeography</b></span><b style="mso-bidi-font-weight: normal;"> </b>which allows us to provide a
first-class programming experience against these types in LINQ and Entity SQL.</p>
<p style="margin-bottom: .0001pt;" class="MsoNormal">One can
describe these types in the <b style="mso-bidi-font-weight: normal;">CSDL</b> in
a straightforward fashion:</p>
<div style="mso-element: para-border-div; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&lt;</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">EntityType</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; font-family: Consolas;">"<span style="color: blue;">Store</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Key</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">PropertyRef</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; font-family: Consolas;">"<span class="SpellE"><span style="color: blue;">StoreId</span></span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Key</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&gt;</span><span style="font-size: 9.5pt; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Property</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; font-family: Consolas;">"<span class="SpellE"><span style="color: blue;">StoreId</span></span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>" <span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Property</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; font-family: Consolas;">"<span style="color: blue;">Name</span>" <span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">String</span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">Property</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; font-family: Consolas;">"<span style="color: blue;">Location</span>"<span style="color: blue;"> </span><span style="color: red; background: yellow; mso-highlight: yellow;">Type</span><span style="color: blue; background: yellow; mso-highlight: yellow;">=</span><span style="background: yellow; mso-highlight: yellow;">"<span style="color: blue;">Geometry</span>"</span><span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="line-height: normal; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&lt;/</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515;">EntityType</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&gt;<o:p></o:p></span></p>
</div>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal">Representing<b style="mso-bidi-font-weight: normal;"> </b>in<b style="mso-bidi-font-weight: normal;">
SSDL</b> is very simple as well:</p>
<div style="mso-element: para-border-div; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242;">
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">&lt;</span><span class="SpellE"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">EntityType</span></span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">"<span style="color: blue;">Stores</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">Key</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">&gt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span class="SpellE"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">PropertyRef</span></span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">"<span class="SpellE"><span style="color: blue;">StoreId</span></span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">Key</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">&gt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;"><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">Property</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">"<span class="SpellE"><span style="color: blue;">StoreId</span></span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span class="SpellE"><span style="color: blue;">int</span></span>"
<span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">Property</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">"<span style="color: blue;">Name</span>" <span style="color: red;">Type</span><span style="color: blue;">=</span>"<span class="SpellE"><span style="color: blue;">nvarchar</span></span>"<span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>" <span class="SpellE"><span style="color: red;">MaxLength</span></span><span style="color: blue;">=</span>"<span style="color: blue;">50</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">Property</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;"> </span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: red;">Name</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">=</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">"<span style="color: blue;">Location</span>"<span style="color: blue;"> </span><span style="color: red; background: yellow; mso-highlight: yellow;">Type</span><span style="color: blue; background: yellow; mso-highlight: yellow;">=</span><span style="background: yellow; mso-highlight: yellow;">"<span style="color: blue;">geometry</span>"</span><span style="color: blue;"> </span><span class="SpellE"><span style="color: red;">Nullable</span></span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">&lt;/</span><span class="SpellE"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: #a31515;">EntityType</span></span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas; color: blue;">&gt;</span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;"><o:p></o:p></span></p>
</div>
<p style="margin-top: 12.0pt;" class="MsoNormal">Be aware that spatial types cannot
be used as entity keys, cannot be used in relationships, and cannot be used as
discriminators.</p>
<p style="margin-top: 12.0pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;" class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><o:p>&nbsp;</o:p></b></p>
<p style="margin-top: 12.0pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;" class="MsoNormal"><span class="GramE"><b style="mso-bidi-font-weight: normal;">Usage<br />
</b>Here are</span> some scenarios and corresponding queries showing how simple
it is to write spatial queries in LINQ:</p>
<p style="margin-top: 12.0pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;" class="MsoNormal"><o:p>&nbsp;</o:p></p>
<table style="border-collapse: collapse; border: none; mso-border-alt: solid #A5A5A5 .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 2.15pt 5.75pt 2.15pt 5.75pt;" cellpadding="0" cellspacing="0" border="1" class="Table">
<tbody>
<tr style="mso-yfti-irow: -1; mso-yfti-firstrow: yes;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; mso-border-alt: solid #A5A5A5 .5pt; background: #5C83B4; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal; mso-yfti-cnfc: 1;" class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white;">Query Scenario<o:p></o:p></span></b></p>
</td>
<td style="width: 378.55pt; border: solid #A5A5A5 1.0pt; border-left: none; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #5C83B4; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-yfti-cnfc: 1;" class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white;">Example<o:p></o:p></span></b></p>
</td>
</tr>
<tr style="mso-yfti-irow: 0;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; border-top: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">Simple Select of Entities with Spatial columns<o:p></o:p></span></p>
</td>
<td style="width: 378.55pt; border-top: none; border-left: none; border-bottom: solid #A5A5A5 1.0pt; border-right: solid #A5A5A5 1.0pt; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: #76923c; mso-themecolor: accent3; mso-themeshade: 191;">// Store is an
  entity type with Location as a Geography type<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> stores = <span style="color: blue;">from</span>
  s <span style="color: blue;">in</span> <span class="SpellE">db.Stores</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span>
  s;<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; border-top: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">Simple Select of Spatial values<o:p></o:p></span></p>
</td>
<td style="width: 378.55pt; border-top: none; border-left: none; border-bottom: solid #A5A5A5 1.0pt; border-right: solid #A5A5A5 1.0pt; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> <span class="SpellE">storeLocations</span>
  = <span style="color: blue;">from</span> s <span style="color: blue;">in</span> <span class="SpellE">db.Stores</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span>
  <span class="SpellE">s.Location</span>;<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; border-top: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">Query with filter, using static constructors<o:p></o:p></span></p>
</td>
<td style="width: 378.55pt; border-top: none; border-left: none; border-bottom: solid #A5A5A5 1.0pt; border-right: solid #A5A5A5 1.0pt; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> store = <span style="color: blue;">from</span>
  s <span style="color: blue;">in</span> <span class="SpellE">db.Stores</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">where</span>
  <span class="SpellE">s.Location</span> == <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="SpellE"><span style="color: #2b91af;">DbGeography</span>.Parse</span>(<span style="color: red; mso-no-proof: yes;">&rdquo;POINT(-122.206834 47.611421)&rdquo;</span>)<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span>
  s;<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 3;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; border-top: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">Query with filter using local variable<o:p></o:p></span></p>
</td>
<td style="width: 378.55pt; border-top: none; border-left: none; border-bottom: solid #A5A5A5 1.0pt; border-right: solid #A5A5A5 1.0pt; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> store = <span style="color: blue;">from</span>
  s <span style="color: blue;">in</span> <span class="SpellE">db.Stores</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">where</span>
  <span class="SpellE">s.Location</span> == <span class="SpellE">loc</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span>
  s;<span style="color: #2b91af;"><o:p></o:p></span></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 4;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; border-top: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">Query involving Spatial methods<o:p></o:p></span></p>
</td>
<td style="width: 378.55pt; border-top: none; border-left: none; border-bottom: solid #A5A5A5 1.0pt; border-right: solid #A5A5A5 1.0pt; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> distances = <span style="color: blue;">from</span> s <span style="color: blue;">in</span> <span class="SpellE">db.Stores</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span>
  <span class="SpellE">s.Location.Distance</span>(<span class="SpellE">anotherLocation</span>);<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 5; mso-yfti-lastrow: yes;">
<td style="width: 136.25pt; border: solid #A5A5A5 1.0pt; border-top: none; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="182">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 8.0pt; mso-bidi-font-size: 10.0pt; font-family: 'Verdana','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">Find all the stores within a mile of a given address<o:p></o:p></span></p>
</td>
<td style="width: 378.55pt; border-top: none; border-left: none; border-bottom: solid #A5A5A5 1.0pt; border-right: solid #A5A5A5 1.0pt; mso-border-top-alt: solid #A5A5A5 .5pt; mso-border-left-alt: solid #A5A5A5 .5pt; mso-border-alt: solid #A5A5A5 .5pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; padding: 2.15pt 5.75pt 2.15pt 5.75pt;" valign="top" width="505">
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> person = <span class="SpellE">db.People.Single</span>(p
  =&gt; <span class="SpellE">p.PersonID</span> == 2);<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman'; color: blue;">var</span></span><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"> stores = <span style="color: blue;">from</span>
  s <span style="color: blue;">in</span> <span class="SpellE">db.Stores</span><o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">where</span>
  <span class="SpellE">s.Location.Distance</span>(<span class="SpellE">person.Address</span>)
  *<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span>.00062 &lt;= 1<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span>
  <span style="color: blue;">new</span> <span style="color: #2b91af;">Location</span>
  <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{ <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Name = <span class="SpellE">s.Name</span>, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Latitude = <span class="SpellE">s.Location.Latitude</span>, <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Longitude = <span class="SpellE">s.Location.Longitude</span> <o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;" class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; mso-fareast-font-family: 'Times New Roman';"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>};<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p style="margin-top: 12.0pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;" class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p style="margin-top: 12.0pt; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;" class="MsoNormal">Have in mind that spatial types are <b style="mso-bidi-font-weight: normal;">immutable</b>, so they can&rsquo;t be modified after
creation. Here is how to create a new location of type <span class="SpellE">DbGeography</span>:
<b style="mso-bidi-font-weight: normal;"><o:p></o:p></b></p>
<div style="mso-element: para-border-div; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242;">
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">s.Location</span></span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;"> = <span class="SpellE"><span class="GramE"><span style="color: #2b91af;">DbGeography</span>.Parse</span></span><span class="GramE">(</span><span style="color: #a31515;">"POINT(-122.206834
47.611421)"</span>);<o:p></o:p></span></p>
<p style="margin-bottom: .0001pt; background: #F2F2F2; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-layout-grid-align: none; text-autospace: none; border: none; mso-border-alt: solid windowtext .5pt; padding: 0in; mso-padding-alt: 1.0pt 4.0pt 1.0pt 4.0pt;" class="MsoNormal"><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">db.SaveChanges</span></span></span><span class="GramE"><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">(</span></span><span style="font-size: 9.5pt; line-height: 115%; font-family: Consolas;">);<o:p></o:p></span></p>
</div>
<h3><span style="font-family: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; color: windowtext; mso-bidi-font-weight: normal;"><o:p>&nbsp;</o:p></span></h3>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">Spatial
Functions<span style="mso-bidi-font-weight: bold;"><o:p></o:p></span></span></b></p>
<p class="MsoNormal">Our Spatial implementation relies on the underlying database
implementation of any of the spatial functions such as Distance, Intersects,
and others. To make this work, we have created the most common functions as
canonical functions on EDM. As a result, Entity Framework will defer the
execution of the function to the server.</p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><o:p>&nbsp;</o:p></b></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;">Client-side Behavior<br />
</b><span class="SpellE">DbGeometry</span> and <span class="SpellE">DbGeography</span>
internally use one of two implementations of <span class="SpellE">DbSpatialServices</span>
for client side behavior which we will make available:</p>
<p class="MsoNormal">One implementation relies on <span class="SpellE">Microsoft.SQLServer.Types.SQLGeography</span>
and <span class="SpellE">Microsoft.SQLServer.Types.SQLGeometry</span> being
available to the client. If these two namespaces are available, then we
delegate all spatial operations down to the SQL assemblies. Note that this
implementation introduces a dependency.</p>
<p class="MsoNormal">Another implementation provides limited services such as
serialization and deserialization, but does not allow performing non-trivial
spatial operations. We create these whenever you explicitly create a spatial
value or <span class="SpellE">deserialize</span> one from a web service.</p>
<p class="MsoNormal"><span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-weight: bold;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span class="SpellE"><b style="mso-bidi-font-weight: normal;"><span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">DataContract</span></b></span><b style="mso-bidi-font-weight: normal;"><span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"> Serialization<span style="mso-bidi-font-weight: bold;"><o:p></o:p></span></span></b></p>
<p class="MsoNormal">Our implementation provides a simple wrapper that is <span class="SpellE">serializable</span>, which allows spatial types to be used in
multi-tier applications. To provide maximum interoperability, we have created a
class called <span class="SpellE">DbWellKnownSpatialValue</span> which contains
the SRID, <span class="SpellE">WellKnownText</span> (WKT), and <span class="SpellE">WellKnownBinary</span> (WKB) values. We will serialize SRID, WKT
and WKB.</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: 13.0pt; mso-bidi-font-size: 11.0pt; line-height: 115%;">Questions<o:p></o:p></span></b></p>
<p class="MsoNormal">We want to hear from you. As we work through this design, it
is vital to hear what you think about our decisions, and that you chime in with
your own ideas. Here are a few questions, please take some time to answer them
in the comments:</p>
<ol>
<li>In order to have client-side spatial functionality,
EF relies on a spatial implementation supplied by the provider. As a default,
EF uses the SQL Spatial implementation. Do you foresee this being a problematic
for Hosted applications which may or may not have access to a spatial
implementation?</li>
<li>Do you feel as though you will need richer
capabilities on the client side?</li>
<li>In addition to Geometry and Geography types, do
you need to have constrained types like Point, Polygon?</li>
<li>Do you foresee using heterogeneous columns of
spatial values in your application?</li>
</ol>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Spatial data is ubiquitous now thanks to the widespread use
of GPS-enabled mobile devices. We are very excited about bringing spatial type
support to the Entity Framework. We encourage you to leave your thoughts on
this design below.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Cheers<span class="GramE">,</span><br />
Pedro Ardila<br />
Program Manager &ndash; Entity Framework Team</p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Unique Constraints in the Entity Framework</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/unique-constraints-in-the-entity-framework</link>
      <pubDate>Wed, 09 Mar 2011 17:44:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/03/09/unique-constraints-in-the-entity-framework/</guid>
      <description><![CDATA[Update: this feature has been postponed and&nbsp;will not be included in Entity Framework 5.
Unique...]]></description>
      <content:encoded><![CDATA[<p style="margin: 24pt 0in 0pt;"><span style="color: #000000;"><strong><span style="font-family: Cambria;">Update: this feature has been postponed and&nbsp;will not be included in Entity Framework 5.</span></strong></span></p>
<h1 style="margin: 24pt 0in 0pt;"><span style="color: #365f91;"><span style="font-family: Cambria;">Unique Constraints in the Entity Framework<o:p></o:p></span></span></h1>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">We&rsquo;ve been busy working on enabling unique constraints in the Entity Framework. Unique Constraints allow you to model candidate keys (also known as alternate keys, or natural keys). This post covers the design of the feature so that we can get some early thoughts and opinions on what you&rsquo;d like to see in this feature.<br /><br /></span></span></p>
<p class="MsoNormal"></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Note:</b> Tooling and the design time experience is an essential part of any Entity Framework feature that we do. However, the motivation of the Design blog is to take a look under the hood of the features as we build them, and therefore we cover XML metadata and code as opposed to what the design time experience will look like. We will have subsequent posts that cover the designer experience.<br /><o:p></o:p></span></span></p>
<h2 style="margin: 10pt 0in 0pt;"><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Background<o:p></o:p></span></span></span></h2>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Being able to model and use Unique Constraints is one of the top requests we hear from the community using Entity Framework. Like a primary key, a unique constraint is a set of properties on an entity whose values identify the entity as unique. Examples of unique constraints might be Social Security Number, Employee Number, Serial Number, etc. Unique constraints are often used to represent a natural and meaningful key, when a generated key is used as a primary key.<br /><br /></span></span></p>
<p class="MsoNormal"></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Most databases support unique constraints today.<span style="mso-spacerun: yes;">&nbsp; </span>F<span style="mso-fareast-language: FR;">oreign key constraints can generally be based on any unique constraint (as opposed to only on the Primary Key) on the principal side.<span style="mso-spacerun: yes;">&nbsp;&nbsp; <br /></span></span><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">A key difference between a unique constraint and an entity key is that null values are allowed in columns that participate in the unique constraint.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">Consider the following example. Here, I have an Employee entity type which includes an <b style="mso-bidi-font-weight: normal;">EmployeeId</b>, as well as a Name and a Social Security Number. <o:p></o:p></span></span></span></p>
<p class="MsoNormal"></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/7870.Employee.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/7870.Employee.jpg" /></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">The <i style="mso-bidi-font-style: normal;">EmployeeId</i> is the entity key, and it serves the purpose of uniquely identifying each Employee entity. However, I also have a <i style="mso-bidi-font-style: normal;">SocialSecurityNumber</i> property that can be used to uniquely identify the entity. This is a unique constriant, and today in the Entity Framework there is no way to specify that this is unique field.<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">This requirement itself is actually pretty self-explanatory, and we might as well say that what&rsquo;s needed is a way to represent this &ldquo;uniqueness&rdquo; in the metadata that describes the entity data model. However, the fact that you can make assumptions about the uniqueness of a given property allows you to take advantage of that fact in interesting ways. For example, DDL generation could leverage this information to generate the corrsponding database constructs .<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;"><br />Taking this example further, let&rsquo;s say I have the following entity data model.<o:p></o:p></span></span></span></p>
<p class="MsoNormal"></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/6888.TaxWitholding.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/6888.TaxWitholding.jpg" /></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">In this case, I now have a few associations that are based on the EmployeeId. What I might actually want in this case is to build one of the associations using <i style="mso-bidi-font-style: normal;">EmployeeId</i> as the foreign key, but build the other association using the <i style="mso-bidi-font-style: normal;">SocialSecurityNumber</i> as the foreign key value &ndash; i.e. in this particular example, it might make sense to build my data model like this instead:<o:p></o:p></span></span></span></p>
<p class="MsoNormal"></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/8032.TaxWitholdingSSN.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/8032.TaxWitholdingSSN.jpg" /></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;"><br />So what I&rsquo;ve done here is that I&rsquo;ve used the unique constriant on <i style="mso-bidi-font-style: normal;">SocialSecurityNumber </i>as the basis for the association between TaxWithholding and Employee. In this particular case, the <i style="mso-bidi-font-style: normal;">SocialSecurityNumber</i> property seems to be more appropriate and pertinent information defining the TaxWitholding entity type. It is also the perfect for acting as a &ldquo;foreign key&rdquo; to the parent Employee. <span style="mso-spacerun: yes;">&nbsp;</span>Because I have a first class association based on this constraint, I am also able to take advantage of the richness in the conceptual model &ndash; like being able to navigate the association using a Navigation Property.<o:p></o:p></span></span></span></p>
<h2 style="margin: 10pt 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Unique Constraints in the Model<o:p></o:p></span></span></span></span></h2>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">Let&rsquo;s take a look at CSDL metadata for Employee and TaxWithholding types, and the association between them:<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmployeeId</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">UniqueConstraint</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Name</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;">&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">PropertyRef</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Name</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;">&gt;&lt;/</span><span style="color: #a31515;">PropertyRef</span><span style="color: blue;">&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;/</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">UniqueConstraint</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Int32</span>"<span style="color: blue;"> </span><span style="color: red;">Name</span><span style="color: blue;">=</span>"<span style="color: blue;">EmployeeId</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">String</span>"<span style="color: blue;"> </span><span style="color: red;">Name</span><span style="color: blue;">=</span>"<span style="color: blue;">Name</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">Property</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Type</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">String</span>"<span style="color: blue;"> </span><span style="color: red;">Name</span><span style="color: blue;">=</span>"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">NavigationProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmployeeDetail</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Relationship</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UniqueModel.EmployeeEmployeeDetail</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">FromRole</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;"> </span><span style="color: red;">ToRole</span><span style="color: blue;">=</span>"<span style="color: blue;">EmployeeDetail</span>"<span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">NavigationProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Relationship</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UniqueModel.EmployeeTaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">FromRole</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;"> </span><span style="color: red;">ToRole</span><span style="color: blue;">=</span>"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;">&gt;<span style="mso-tab-count: 1;"> </span><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp; </span></span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Int32</span>"<span style="color: blue;"> </span><span style="color: red;">Name</span><span style="color: blue;">=</span>"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Int32</span>"<span style="color: blue;"> </span><span style="color: red;">Name</span><span style="color: blue;">=</span>"<span style="color: blue;">NumberOfDependents</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">NavigationProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Relationship</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UniqueModel.EmployeeTaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">FromRole</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;"> </span><span style="color: red;">ToRole</span><span style="color: blue;">=</span>"<span style="color: blue;">Employee</span>"<span style="color: blue;"> /&gt;<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Association</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"FK_<span style="color: blue;">Employee_TaxWithholding</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Model.Employee</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Multiplicity</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">1</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Model.TaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Multiplicity</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">0..1</span>"<span style="color: blue;"> /&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: #a31515;">ReferentialConstraint</span><span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;</span><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">Principal</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Role</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">Employee</span>"<span style="color: blue;">&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">PropertyRef</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Name</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;/</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">Principal</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Dependent</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Dependent</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReferentialConstraint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Association</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="mso-no-proof: yes;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">Foreign Key Associations may be based on a Unique Constraint on the principal end. The ReferentialConstraint element above shows exactly this scenario.<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></span></p>
<p class="MsoNoSpacing"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">In order to represent unique constraints as they are defined in the store / database, Store Metadata (SSDL) also includes the ability to specify unique constraints as they are defined on the database schema. Here&rsquo;s the corresponding SSDL for the above example: <o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employees</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmployeeId</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="background: yellow; color: blue; mso-highlight: yellow;">&lt;UniqueConstraint Name=&ldquo;SocialSecurityNumber</span><span style="background: yellow; mso-highlight: yellow;">"<span style="color: blue;">&gt;</span></span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="line-height: 115%; font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">PropertyRef</span><span style="line-height: 115%; font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="line-height: 115%; font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Name</span><span style="line-height: 115%; font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="line-height: 115%; font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span></span><span style="line-height: 115%; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;/UniqueConstraint&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmployeeId</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">int</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Name</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">nvarchar(max)</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">Property</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Name</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">nvarchar(max)</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholdings</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmployeeId</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Key</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmployeeId</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">int</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">nvarchar(max)</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NumberOfDependents</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">nvarchar(max)</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NumberOfAllowances</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">nvarchar(max)</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Association</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholdingEmployee</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Store.TaxWithholdings</span>"<span style="color: blue;"> </span><span style="color: red;">Multiplicity</span><span style="color: blue;">=</span>"<span style="color: blue;">0..1</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Store.Employees</span>"<span style="color: blue;"> </span><span style="color: red;">Multiplicity</span><span style="color: blue;">=</span>"<span style="color: blue;">1</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReferentialConstraint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">Principal</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Role</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">Employee</span>"<span style="color: blue;">&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">PropertyRef</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Name</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;/</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">Principal</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Dependent</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Dependent</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReferentialConstraint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Association</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">The details specified in SSDL are very similar to what is specified in the CSDL. A Unique Constraint in CSDL can map to a Unique constraint on the SSDL implicitly, based on how the columns are mapped in the MSL metadata. Nothing additional needs to be specified.<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></span></p>
<p class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Here are some more details with regards to how Unique constraints can be specified:</span></span></span></p>
<ul>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">In many ways unique constraints are similar to entity keys:</span></span></span></div>
<ul>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Unique constraints will be supported on Entity Type</span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">More than one scalar property may compose a Unique constraint.</span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Server generated values can participate in a unique constraint</span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Navigation Properties may not participate in a unique constraint. </span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Associations can be based on unique constraints</span></span></span></div>
</li>
</ul>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">However, unlike Entity Keys:</span></span></span></div>
<ul>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Unique constraints have names to identify them. These names should be unique within a type hierarchy.</span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Nullable properties may participate in unique constraints</span></span></span></div>
</li>
</ul>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">A given property can participate in more than one unique constraint. </span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;">Properties participating in unique constraint may be mutable</span></span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="mso-no-proof: yes;"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span></span><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Calibri;">Unique constraints may include properties from a base type<o:p></o:p></span></span></span></div>
</li>
</ul>
<p class="MsoListParagraphCxSpLast"><span style="mso-no-proof: yes;"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></span></p>
<h2 style="margin: 10pt 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Support for OnUpdate cascading behavior<o:p></o:p></span></span></span></span></h2>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Unlike Primary Keys, Entity Framework will support mutability on properties that participate in a unique constraint.<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><br />Along with that, we plan on supporting <b style="mso-bidi-font-weight: normal;">OnUpdate</b> cascading behavior.<span style="mso-spacerun: yes;">&nbsp; </span>This is something that is supported by databases. It simply allows you to specify that when the principal end of the relationship changes, the dependent end should be automatically updated accordingly as well. <br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Cascading is only handled for entities and relationships that are loaded into the object state manager. If you have <b style="mso-bidi-font-weight: normal;">OnUpdate</b> <i style="mso-bidi-font-style: normal;">Cascade</i> behavior specified in the model, it will most certainly also make sense to make sure that the database itself has the same <b style="mso-bidi-font-weight: normal;">OnUpdate</b> <i style="mso-bidi-font-style: normal;">Cascade</i> specification so that the database will manage the referential integrity of your data. This is equivalent to the <b style="mso-bidi-font-weight: normal;">OnDelete</b> Cascade behavior supported today for associations based on primary keys. <br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><br />This is how you can specify <b style="mso-bidi-font-weight: normal;">OnUpdate</b> <i style="mso-bidi-font-style: normal;">Cascade</i> behavior:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Association</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholdingEmployee</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Type</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Store.TaxWithholdings</span>"<span style="color: blue;"> </span><span style="color: red;">Multiplicity</span><span style="color: blue;">=</span>"<span style="color: blue;">0..1</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Store.Employees</span>"<span style="color: blue;"> </span><span style="color: red;">Multiplicity</span><span style="color: blue;">=</span>"<span style="color: blue;">1</span>"<span style="color: blue;">&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background: yellow; mso-highlight: yellow;">&lt;</span></span><span style="font-family: Consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow;">OnUpdate</span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow;">Action</span><span style="font-family: Consolas; background: yellow; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: yellow;">=</span><span style="font-family: Consolas; background: yellow; font-size: 9.5pt; mso-highlight: yellow;">"<span style="color: blue;">Cascade</span>"</span><span style="font-family: Consolas; background: yellow; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: yellow;"> </span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow;">/&gt;</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">End</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReferentialConstraint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Principal</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Employee</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Principal</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Dependent</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Role</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">TaxWithholding</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">PropertyRef</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SocialSecurityNumber</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Dependent</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReferentialConstraint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Association</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">The default Action for <b style="mso-bidi-font-weight: normal;">OnUpdate</b> is &ldquo;None&rdquo;.<o:p></o:p></span></span></p>
<h2 style="margin: 10pt 0in 0pt;"><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">What mapping scenarios are not supported?<o:p></o:p></span></span></span></h2>
<p class="MsoNormal"><span style="font-family: Calibri;"><span style="font-size: small;">We are still contemplating exactly what set of capabilities might not make it into the next release with regards to the unique constraint support&ndash; therefore your feedback on this will be of significant value to us.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span style="font-size: small;">As it stands right now, the following scenarios will <b style="mso-bidi-font-weight: normal;">*NOT*</b> be supported:</span></span></p>
<ul>
<li>
<div class="MsoNormal"><span style="font-family: Calibri;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Split Entities based on Unique Constraints</b> &ndash; this is the scenario where a single entity is split across multiple tables on the database, where the split/join is based on a Unique Constraint instead of Primary Key.</span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="font-family: Calibri;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Inheritance Support with Unique Constraints</b> &ndash; Support mapping inheritance based on unique constraints as opposed to primary key&nbsp;</span></span></div>
</li>
<li>
<div class="MsoNormal"><span style="font-family: Calibri;"><span style="font-size: small;"></span></span><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;"><span style="font: 7pt 'Times New Roman';">&nbsp;</span></span></span><span style="font-family: Calibri;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Independent Association based on Unique Constraints </b>&ndash; This is the association type that was present in Entity Framework 3.5SP1 (as opposed to the Foreign Key Associations that we released in Entity Framework 4.0). In theory it is possible to enable Independent associations to store the foreign key values based on unique constraints but we are considering not supporting it because of the popularity of Foreign Key Associations as the standard way of representing associations.</span></span></div>
</li>
</ul>
<p class="MsoListParagraphCxSpLast"></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span style="font-size: small;"><br />We would like to know more about whether you need the following capabilities:</span></span></p>
<p class="MsoNormal"></p>
<ul>
<li>
<div class="MsoNoSpacing"><span style="font-family: Calibri;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Associations based on unique constraints</b> &ndash; Do you see the need to form associations using unique constraints where you are associating to a unique constraint on the principal end instead of the primary key on that entity? Is this something you see in existing/legacy databases?</span></span></div>
</li>
<li>
<div class="MsoNoSpacing"><span style="font-size: small;"><span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Mutability of Unique Constraints </b>&ndash; Mutability of unique constraints are important. However, if you are associating to a unique constraint on the principal end, how important is mutability in this scenario? <o:p></o:p></span></span></div>
</li>
</ul>
<p class="MsoNoSpacing"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;<br /></span></o:p><span style="font-size: small;"><span style="font-family: Calibri;">Once again, the purpose of this post is to find out how you&rsquo;d like to see the feature built &ndash; so please feel free to tell us what your own preferences would be around this feature.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><br />Please let us know what you think!<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><br />Faisal Mohamood &ndash; Program Manager, Entity Framework<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Kati Iceva &ndash; Software Design Engineer, Entity Framework<o:p></o:p></span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Table-Valued Function Support</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/table-valued-function-support</link>
      <pubDate>Fri, 21 Jan 2011 17:07:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2011/01/21/table-valued-function-support/</guid>
      <description><![CDATA[One of the key features coming in the next release of Entity Framework is Table-Valued Function...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">One of the key features coming in the next release of Entity Framework is Table-Valued Function support.<span style="mso-spacerun: yes;">&nbsp; </span>It is a very popular customer request and we have been working diligently to design a solution that we hope you find simple, yet useful.<span style="mso-spacerun: yes;">&nbsp; </span>This design intends to make TVFs first-class citizens on Entity Framework, by allowing a user to map TVFs to both Entities and Complex types.<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">This article will explore the design of the feature in the framework, so we will focus on the metadata within the EDMX as opposed to the designer experience in Visual Studio.<span style="mso-spacerun: yes;">&nbsp; </span>We will cover that experience in a later post.<span style="mso-spacerun: yes;">&nbsp; </span>Other topics we will cover in the future include QueryViews and other complex Function Mapping scenarios.<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">With that said, here are the specific areas we will cover now:<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">A basic overview of TVFs; pros and cons vs. Stored Procedures and Views<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">How to call a TVF Directly<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Mapping a TVF to a Collection of Complex type<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Mapping a TVF to a Collection of Entity type and performing CRUD on the Entity<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">We&rsquo;d love to hear your thoughts, so please feel free to comment and make suggestions about any part of this design.<br /><br /><o:p></o:p></span></span></span></p>
<h1 style="margin: 0in 0in 0pt;"><span style="font-size: medium;"><span style="color: #365f91;"><span style="font-family: Segoe UI;">What Are TVFs?<span class="MsoSubtleEmphasis"><o:p></o:p></span></span></span></span></h1>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">TVFs are User Defined Functions (UDFs) which live in the target database and whose return type is a table.<span style="mso-spacerun: yes;">&nbsp; </span>UDFs are constructs made up of one or more T-SQL statements.<span style="mso-spacerun: yes;">&nbsp; </span>In the context of a T-SQL query, TVFs can be used anywhere a View or a Table would be used.<span style="mso-spacerun: yes;">&nbsp; </span>Although there is some overlap between TVFs, Views, and Stored Procedures, there are key advantages which make TVFs appealing in certain scenarios.<span style="mso-spacerun: yes;">&nbsp; </span>Let&rsquo;s look at how TVFs stack up against Views and Stored Procedures:<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">TVFs vs. Views</b><br />TVFs and Views are similar in that they are both composable.<span style="mso-spacerun: yes;">&nbsp; </span>This means that you can use the function&mdash;or the view&mdash;anywhere within the body of a T-SQL query.<span style="mso-spacerun: yes;">&nbsp; </span>Their major differences are, first, that SQL Views can only have one SELECT statement, whereas TVFs can have multiple statements as well as procedural code.<span style="mso-spacerun: yes;">&nbsp; </span>This makes it possible to design more complex logic with TVFs than with Views.<span style="mso-spacerun: yes;">&nbsp; </span>Additionally, TVFs can take parameters, whereas Views cannot.<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">TVFs vs. Stored Procedures</b><br />TVFs and stored procedures may both contain procedural code, but unlike stored procedures, TVFs can be used anywhere in a query.<span style="mso-spacerun: yes;">&nbsp; </span>This allows us to both compose queries using TVFs and filter the result set of a TVF.<span style="mso-spacerun: yes;">&nbsp; </span>One advantage of stored procedures over TVFs is that stored procedures are capable of returning multiple result sets.<br /><br /><o:p></o:p></span></span></p>
<h3 style="margin: 10pt 0in 0pt;"><span style="color: #4f81bd;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Background: TVF declaration and usage in SQL <o:p></o:p></span></span></span></h3>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">TVFs allow you to write complex statements and queries, all in the same place.<span style="mso-spacerun: yes;">&nbsp; </span>In this post we will use relatively simple TVFs in order to keep complexity low.<span style="mso-spacerun: yes;">&nbsp; </span>Please read </span></span><a href="https://msdn.microsoft.com/en-us/library/ms191165.aspx"><span style="font-family: Segoe UI; color: #0000ff;"><span style="font-size: small;">this article</span></span></a><span style="font-family: Segoe UI;"><span style="font-size: small;"> to learn more about TVFs in SQL.<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">Throughout the post we will use these two TVFs to showcase functionality:<o:p></o:p></span></span></p>
<p class="MsoListParagraph"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;"><b style="mso-bidi-font-weight: normal;">GetCategories() </b>returns all of the entries in the Categories table.<br /><br /><o:p></o:p></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4%; padding-right: 5.4pt; height: 3pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">1.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">2.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">3.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">4.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">5.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">6.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">7.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">8.<o:p></o:p></span></span></p>
</td>
<td width="96%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 96%; padding-right: 5.4pt; height: 3pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">CREATE FUNCTION</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> [dbo]<span style="color: gray;">.</span>[GetCategories]<span style="color: gray;">()<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">RETURNS</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">TABLE<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">RETURN<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">SELECT</span> [CategoryID]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[CategoryName]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[Description]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[Picture]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">FROM</span> [dbo]<span style="color: gray;">.</span>[Categories]<span style="color: gray;"><o:p></o:p></span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoListParagraph"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;"><br /><br />&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;"><b style="mso-bidi-font-weight: normal;">GetDetailsForOrder(int) </b>returns the Order Details for a given order for Id equal to Oid.<br /><br /><o:p></o:p></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4%; padding-right: 5.4pt; height: 3pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">1.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">2.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">3.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">4.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">5.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">6.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">7.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">8.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">9.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">10.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">11.<o:p></o:p></span></span></p>
</td>
<td width="96%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 96%; padding-right: 5.4pt; height: 3pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">CREATE FUNCTION</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> [dbo]<span style="color: gray;">.</span>[GetDetailsForOrder]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: gray; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">(</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">@Oid <span style="color: blue;">INT</span><span style="color: gray;">)</span><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">RETURNS</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">TABLE<o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">RETURN</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">SELECT </span>[OrderID]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[ProductID]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[UnitPrice]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[Quantity]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: gray;">,</span>[Discount]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>FROM</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> [dbo]<span style="color: gray;">.</span>[OrderDetails]<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">WHERE</span> OrderID <span style="color: gray;">=</span> @Oid<span style="color: gray;"><o:p></o:p></span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />Typical usage of a TVF in T-SQL as follows:<br /><br /><o:p></o:p></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3.5pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.78%; padding-right: 5.4pt; height: 3.5pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">1.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"><span style="font-size: x-small;">2.<o:p></o:p></span></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.22%; padding-right: 5.4pt; height: 3.5pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">SELECT</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> d<span style="color: gray;">.</span>ProductID<span style="color: gray;">,</span> d<span style="color: gray;">.</span>Quantity<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: 'Courier New'; color: blue; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;">FROM</span><span style="font-family: 'Courier New'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes;"> dbo<span style="color: gray;">.</span>GetDetailsForOrder<span style="color: gray;">(</span>10248<span style="color: gray;">)</span> <span style="color: blue;">AS</span> d<span style="color: gray;"><o:p></o:p></span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />This simple statement returns the category ID and Category Name from our TVF.<br /><br /><o:p></o:p></span></span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; mso-border-alt: solid windowtext .5pt; mso-element: para-border-div; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas;"><span style="font-size: x-small;">ProductID<span style="mso-spacerun: yes;">&nbsp;&nbsp; </span>Quantity<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span style="font-size: x-small;">----------- --------<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>11<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>12<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>42<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>10<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas;"><span style="font-size: x-small;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>72<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>5<o:p></o:p></span></span></p>
</div>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />Note that we were able to call the TVF in the FROM clause of our T-SQL query, as we would a table.<span style="mso-spacerun: yes;">&nbsp; </span>Also note that we were able to pass in parameters, and that the result of the query was a table.<span style="mso-spacerun: yes;">&nbsp; </span>This combination of factors, as well as the possibility to have procedural code within your function, is what makes TVFs appealing.<br /><br /><o:p></o:p></span></span></span></p>
<h3 style="margin: 10pt 0in 0pt;"><span style="color: #4f81bd;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Why Should You Use TVFs in EF?<o:p></o:p></span></span></span></span></h3>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">If you already use TVFs, the advantages of having EF support are obvious: You will now be able to use your TVFs as the source for materializing entity types and complex types via queries in EF &ndash; giving you the ability to use LINQ and Entity SQL against them. <span style="mso-spacerun: yes;">&nbsp;</span>If you don&rsquo;t already use TVFs, think about the potential we get from creating Entity or Complex type that is backed by a function instead of an entity.<span style="mso-spacerun: yes;">&nbsp; </span>TVF support enables interesting scenarios such as </span></span><a href="https://msdn.microsoft.com/en-us/library/cc721269(v=sql.100).aspx"><span style="font-family: Segoe UI; color: #0000ff;"><span style="font-size: small;">Full-Text search</span></span></a><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"> since in SQL, it is implemented using TVFs.<br /><br /><o:p></o:p></span></span></span></p>
<h1 style="margin: 0in 0in 0pt;"><span style="font-size: medium;"><span style="color: #365f91;"><span style="font-family: Segoe UI;">Using TVFs in Entity Framework<o:p></o:p></span></span></span></h1>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">Now that we&rsquo;ve established what a TVF is, let&rsquo;s see what artifacts we need in order to use one in an EF app:<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Metadata describing the store function and its return type.<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">A function stub is required to call the function from a LINQ query.<span style="mso-spacerun: yes;">&nbsp; </span>The stub is not required for Entity SQL queries.<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">These two items are all we need if we want to call the TVF directly in a LINQ or Entity SQL query. <span style="mso-spacerun: yes;">&nbsp;</span>However, to truly take advantage TVFs in EF (reusability, change tracking, CUD), we also need to describe the mapping of the function to a Collection of Entity Type or Collection of Complex Type.<br /><br /><o:p></o:p></span></span></span></p>
<h2 style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="color: #4f81bd;"><span style="font-family: Segoe UI;">TVFs as Functions in SSDL returning RowType<o:p></o:p></span></span></span></h2>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><strong>Storage Layer<br /></strong>In order to make the TVF visible to Entity Framework, we must declare the store function in the storage layer (SSDL). <span style="mso-spacerun: yes;">&nbsp;</span>We must specify the function name, whether or not it is composable, and the schema it belongs to.<span style="mso-spacerun: yes;">&nbsp; </span>Up until version 4 of EF, the </span></span></span><a href="https://msdn.microsoft.com/en-us/library/bb738614.aspx"><span style="font-family: Segoe UI; color: #0000ff;"><span style="font-size: small;">Function</span></span></a><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"> node was only capable of returning a scalar.<span style="mso-spacerun: yes;">&nbsp; </span>Our new design required us to make two changes to this node: First, we can now set IsComposable to true, and therefore we are able to compose functions.<span style="mso-spacerun: yes;">&nbsp; </span>Second, the return type is no longer a property of Function, but instead a child node in which we can describe the rich return types produced by TVFs.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Here is how we declare the store function called GetCategories in our SSDL:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="5%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 5.24%; padding-right: 5.4pt; height: 3pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
</td>
<td width="94%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 94.76%; padding-right: 5.4pt; height: 3pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;!--</span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">SSDL</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">GetCategories</span>"<span style="color: blue;"> </span><span style="color: red;">IsComposable</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: red;"> Schema</span><span style="color: blue;">=</span>"<span style="color: blue;">dbo</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReturnType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">CollectionType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">RowType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">CategoryID</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">int</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">CategoryName</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">nvarchar</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> </span><span style="color: red;">MaxLength</span><span style="color: blue;">=</span>"<span style="color: blue;">15</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Description</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">ntext</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Picture</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">image</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">RowType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">CollectionType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReturnType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />Here we specify the ReturnType of the Function.<span style="mso-spacerun: yes;">&nbsp; </span>In this case it will be a collection of RowTypes.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Object Layer</b><br />We need a function stub to refer to the store function from a LINQ query.<span style="mso-spacerun: yes;">&nbsp; </span>The result of calling the function stub is a set of unstructured rows.<span style="mso-spacerun: yes;">&nbsp; </span>See this </span></span></span><a href="https://blogs.msdn.com/b/efdesign/archive/2008/10/08/edm-and-store-functions-exposed-in-linq.aspx"><span style="font-family: Segoe UI; color: #0000ff;"><span style="font-size: small;">design blog</span></span></a><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"> to learn more about function stubs. <span style="mso-spacerun: yes;">&nbsp;</span>Here is what the stub will look like:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 2.5pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.14%; padding-right: 5.4pt; height: 2.5pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.86%; padding-right: 5.4pt; height: 2.5pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">EdmFunction</span>(<span style="color: #a31515;">"NorthwindModel.Store"</span>, <span style="color: #a31515;">"GetCategories"</span>)]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">IQueryable</span>&lt;<span style="color: #2b91af;">DbDataRecord</span>&gt; GetCategoriesDirect()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> <span style="color: blue;">this</span>.CreateQuery&lt;<span style="color: #2b91af;">DbDataRecord</span>&gt;(<span style="color: #a31515;">"[NorthwindModel.Store].[GetCategories]()"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />This stub will usually reside within your strongly typed ObjectContext class.<span style="mso-spacerun: yes;">&nbsp; </span>Here are a few things to take note of:<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">The stub returns a collection of DbDataRecord.<span style="mso-spacerun: yes;">&nbsp; </span>These records aren&rsquo;t richly typed and therefore only provide us with limited functionality.<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">The EdmFunction attribute is the store&rsquo;s namespace since we are calling a store function.<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Our function stub contains a meaningful body, as opposed to an exception (see </span></span><a href="https://msdn.microsoft.com/en-us/library/dd456847.aspx"><span style="font-family: Segoe UI; color: #0000ff;"><span style="font-size: small;">here</span></span></a><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"> for an example).<span style="mso-spacerun: yes;">&nbsp; </span>This &lsquo;bootstrapping&rsquo; allows us to call the function in the FROM clause of our LINQ query.<span style="mso-spacerun: yes;">&nbsp; </span>Here is exactly how we would call our TVF:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 27.4pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.14%; padding-right: 5.4pt; height: 27.4pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.86%; padding-right: 5.4pt; height: 27.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">var</span> context = <span style="color: blue;">new</span> <span style="color: #2b91af;">NorthwindEntities</span>())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: green; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>//Call GetCategories directly using Entity LINQ</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> query = <span style="color: blue;">from</span> c <span style="color: blue;">in</span> context.GetCategoriesDirect()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span> c;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> r <span style="color: blue;">in</span> query)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"[{0}] {1}"</span>, r.GetInt32(0), r.GetString(1));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<h2 style="margin: 0in 0in 0pt;"><o:p><span style="font-family: Segoe UI; color: #4f81bd; font-size: small;">&nbsp;</span></o:p></h2>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">The stub is not required when using Entity SQL for our queries.<span style="mso-spacerun: yes;">&nbsp; </span>Here is how to call the same TVF in Entity SQL:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 2.8pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.14%; padding-right: 5.4pt; height: 2.8pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.86%; padding-right: 5.4pt; height: 2.8pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">var</span> context = <span style="color: blue;">new</span> <span style="color: #2b91af;">NorthwindEntities</span>())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: green; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>//Call GetCategories directly using Entity SQL</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> query = <span style="color: #a31515;">@"Select Category.CategoryId, Category.CategoryName<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>From NorthwindModel.Store.getCategories() as Category"</span><span style="font-family: Consolas; font-size: 9.5pt;">;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> categories = context.CreateQuery&lt;<span style="color: #2b91af;">DbDataRecord</span>&gt;(query);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: #2b91af;">DbDataRecord</span> category <span style="color: blue;">in</span> categories)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"[{0}]: {1}"</span>, category.GetInt32(0), category.GetString(1));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />The functionality above is useful, but only to a limited extent since unstructured data records are read only.<br /><br /><o:p></o:p></span></span></span></p>
<h2 style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="color: #4f81bd;"><span style="font-family: Segoe UI;">Mapping TVF to Complex Types and Entity Types<o:p></o:p></span></span></span></h2>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Function Mapping is a new feature which allows us to map the TVF&rsquo;s results to a collection of Complex Type as well as a collection of Entity Type.<span style="mso-spacerun: yes;">&nbsp; </span>By mapping to an Entity Type, we gain full CRUD functionality against our entities. <span style="mso-spacerun: yes;">&nbsp;</span>The first step is to specify the function mapping in the mapping layer.<o:p></o:p></span></span></span></p>
<h3 style="margin: 10pt 0in 0pt;"><span style="color: #4f81bd;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Result Type Mapping<o:p></o:p></span></span></span></span></h3>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Below we map a function in the conceptual layer to a function in the storage layer with an explicit return type mapping.<span style="mso-spacerun: yes;">&nbsp; </span>Explicit mapping is supported for conceptual functions returning collection of Complex Type or a collection of Entity Type.<span style="mso-spacerun: yes;">&nbsp; </span>Using explicit mapping, we describe how each property in the conceptual function will map to a property in the store function.<span style="mso-spacerun: yes;">&nbsp; </span>We could use implicit mapping, but only for conceptual functions returning a scalar or a collection of Rowtype with primitive properties.<o:p></o:p></span></span></span></p>
<h3 style="margin: 10pt 0in 0pt;"><span style="color: #4f81bd;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Collection of Complex Type<o:p></o:p></span></span></span></span></h3>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">A TVF&rsquo;s result set can map to a collection Complex Type.<span style="mso-spacerun: yes;">&nbsp; </span>This is the default behavior when using Model First or EDMGen.<span style="mso-spacerun: yes;">&nbsp; </span>Let&rsquo;s explore this mapping using GetDetailsForOrder:<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Storage Layer<br /><o:p></o:p></span></span></span></b></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 3pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">14.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">15.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">16.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 3pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;!--</span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">SSDL</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">GetDetailsForOrder</span>"<span style="color: blue;"> </span><span style="color: red;">IsComposable</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;"> </span><span style="color: red;">Schema</span><span style="color: blue;">=</span>"<span style="color: blue;">dbo</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Oid</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">int</span>"<span style="color: blue;"> </span><span style="color: red;">Mode</span><span style="color: blue;">=</span>"<span style="color: blue;">In</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReturnType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">CollectionType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">RowType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">OrderID</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">int</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">ProductID</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">int</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UnitPrice</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">money</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Quantity</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">smallint</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Discount</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">real</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">RowType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">CollectionType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ReturnType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />Mapping Layer<o:p></o:p></span></span></span></b></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">To tie the function to a collection of Complex Types, we need to create a mapping between our store function and a conceptual function.<span style="mso-spacerun: yes;">&nbsp; </span>We do that in the following way:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3.2pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 3.2pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">14.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">15.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">16.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 3.2pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;!--</span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">MSL</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">--&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">FunctionMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">StorageFunction</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NorthwindModel.Store.GetDetailsForOrder</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="color: red;">CdmFunction</span><span style="color: blue;">=</span>"<span style="color: blue;">NorthwindModel.GetDetailsForOrder</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameters</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">TypeName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Edm.Int32</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameters</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ResultMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ComplexTypeMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">OrderID</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">OrderID</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">ProductID</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">ProductID</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UnitPrice</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">UnitPrice</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Quantity</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">Quantity</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Discount</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">Discount</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ComplexTypeMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ResultMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">FunctionMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />The explicit mapping above describes how to map the columns returned by the TVF to our Complex Type&rsquo;s properties.<span style="mso-spacerun: yes;">&nbsp; </span>It also describes the parameters.<span style="mso-spacerun: yes;">&nbsp; </span>In this iteration we will only support parameters of Primitive type.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Conceptual Layer<o:p></o:p></span></span></span></b></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Finally we need a conceptual function whose return type is a collection of Complex Types.<span style="mso-spacerun: yes;">&nbsp; </span>The Complex type and the function look like the following:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 2.8pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 2.8pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 2.8pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;!--</span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">CSDL</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ComplexType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">GetDetailsForOrder_Result</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">OrderID</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">ProductID</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UnitPrice</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Decimal</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> </span><span style="color: red;">Precision</span><span style="color: blue;">=</span>"<span style="color: blue;">19</span>"<span style="color: blue;"> </span><span style="color: red;">Scale</span><span style="color: blue;">=</span>"<span style="color: blue;">4</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Quantity</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int16</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Property</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Discount</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Single</span>"<span style="color: blue;"> </span><span style="color: red;">Nullable</span><span style="color: blue;">=</span>"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ComplexType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&hellip;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">GetDetailsForOrder</span>"<span style="color: blue;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">ReturnType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Collection(NorthwindModel.GetDetailsForOrder_Result)</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Oid</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />In the code above we declared a complex type then we created a function which returns a collection of such type.<span style="mso-spacerun: yes;">&nbsp; </span>EDMGen uses &ldquo;&lt;FunctionMame&gt;_result&rdquo; as the Complex Type&rsquo;s name by default when generating metadata.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Object Layer<o:p></o:p></span></span></span></b></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Once these are in place we can use call TVF using Entity SQL. <span style="mso-spacerun: yes;">&nbsp;</span>However, we need a new function stub to use the TVF in a LINQ query:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 2.5pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.14%; padding-right: 5.4pt; height: 2.5pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.86%; padding-right: 5.4pt; height: 2.5pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">EdmFunction</span>(<span style="color: #a31515;">"NorthwindModel"</span>, <span style="color: #a31515;">"GetDetailsForOrder"</span>)]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">IQueryable</span>&lt;<span style="color: #2b91af;">GetDetailsForOrder_Result</span>&gt; GetDetailsForOrder(<span style="color: blue;">int</span> Oid)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> <span style="color: blue;">this</span>.CreateQuery&lt;<span style="color: #2b91af;">GetDetailsForOrder_Result</span>&gt;(<span style="color: #a31515;">"NorthwindModel.GetDetailsForOrder(@Oid)"</span>,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>new</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">ObjectParameter</span>(<span style="color: #a31515;">"Oid"</span>, Oid));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />The noteworthy differences from our first stub are that this one returns a collection of Complex Type, rather than a collection of unstructured records. <span style="mso-spacerun: yes;">&nbsp;</span>Also, note that the first parameter in the EdmFunction attribute is the <b style="mso-bidi-font-weight: normal;">conceptual function</b>, as opposed to the store function.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Usage<br /></b>Let&rsquo;s have a look at the basic usage of our function in LINQ and Entity SQL.<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 27.4pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 27.4pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 27.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">var</span> context = <span style="color: blue;">new</span> <span style="color: #2b91af;">NorthwindEntities</span>())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span> OrderId = 10248;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//GetDetailsForOrder using LINQ</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> OrderDetails = <span style="color: blue;">from</span> O <span style="color: blue;">in</span> context.GetDetailsForOrder(OrderId)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">select</span> O;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> od <span style="color: blue;">in</span> OrderDetails)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"[{0}] {1}"</span>, od.OrderID, od.ProductID);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
<tr style="height: 13.45pt; mso-yfti-irow: 1; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 13.45pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">14.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 13.45pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">var</span> context = <span style="color: blue;">new</span> <span style="color: #2b91af;">NorthwindEntities</span>())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span> OrderId = 10248;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//GetDetailsForOrder using Entity SQL</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> queryString = <span style="color: #a31515;">@"Select VALUE OrderDetail<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>From NorthwindModel.GetDetailsForOrder(@Oid) as OrderDetail"</span><span style="font-family: Consolas; font-size: 9.5pt;">;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">ObjectQuery</span>&lt;<span style="color: #2b91af;">GetDetailsForOrder_Result</span>&gt; OrderDetailsQuery =<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">new</span> <span style="color: #2b91af;">ObjectQuery</span>&lt;<span style="color: #2b91af;">GetDetailsForOrder_Result</span>&gt;(queryString, context);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>OrderDetailsQuery.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">ObjectParameter</span>(<span style="color: #a31515;">"Oid"</span>, OrderId));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> result <span style="color: blue;">in</span> OrderDetailsQuery)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"[{0}] {1}"</span>, result.OrderID, result.ProductID);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<span style="color: blue;"><o:p></o:p></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />Both samples do the same.<span style="mso-spacerun: yes;">&nbsp; </span>They call GetDetailsForOrder with an OrderId of 10248 and then iterate over the result.<br /><br /><o:p></o:p></span></span></span></p>
<h3 style="margin: 10pt 0in 0pt;"><span style="color: #4f81bd;"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">Collection of Entity Type<o:p></o:p></span></span></span></span></h3>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">We can also make our TVF return entities.<span style="mso-spacerun: yes;">&nbsp; </span>We get all of the functionality we would expect from entities, such as reading, writing, and navigation provided by using NavigationProperties.<span style="mso-spacerun: yes;">&nbsp; </span>EDMGen does not map to Entities by default, but we intend to provide tooling support to create such mapping without having to edit the EDMX.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Storage Layer<br /></b>The store function definition remains the same as described above.<br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Mapping Layer</b><br />Now we need to describe the mapping between the store function and the conceptual function.<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 3pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 3pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">14.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">15.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">16.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 3pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;!--</span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">MSL</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">--&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">FunctionMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">StorageFunction</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NorthwindModel.Store.GetDetailsForOrder</span>"<span style="color: blue;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: red; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CdmFunction</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NorthwindModel.GetDetailsForOrderAsEntity</span>"<span style="color: blue;"> &gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameters</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">TypeName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Edm.Int32</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameters</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ResultMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityTypeMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">TypeName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NorthwindModel.OrderDetails</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">OrderID</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">OrderID</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">ProductID</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">ProductID</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UnitPrice</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">UnitPrice</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Quantity</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">Quantity</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ScalarProperty</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Discount</span>"<span style="color: blue;"> </span><span style="color: red;">ColumnName</span><span style="color: blue;">=</span>"<span style="color: blue;">Discount</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">EntityTypeMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ResultMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">FunctionMapping</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />This mapping describes the TVF&rsquo;s parameters and maps the function&rsquo;s result to a collection of Entity types named OrderDetails.<span style="mso-spacerun: yes;">&nbsp; </span>Each ScalarProperty node has two properties, Name and ColumnName.<span style="mso-spacerun: yes;">&nbsp; </span>Name refers to the EntityType and ColumnName refers to the Store function.<span style="mso-spacerun: yes;">&nbsp; </span>Function Mapping supports Table-Per-Hierarchy inheritance, much like in FunctionImportMapping.<span style="mso-spacerun: yes;">&nbsp; </span>This topic will be covered in a later post.<br /><br /><br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Conceptual Layer<br /></b>When you map a function to a collection of Entity types, you get the following in the CSDL:<br /><br /><br /><br /><b style="mso-bidi-font-weight: normal;"><o:p></o:p></b></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 10.75pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 10.75pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 10.75pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;!--</span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">CSDL</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">GetDetailsForOrderAsEntity</span>"<span style="color: blue;"> </span><span style="color: red;">ReturnType</span><span style="color: blue;">=</span>"<span style="color: blue;">Collection(NorthwindModel.OrderDetails)</span>"<span style="color: blue;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">EntityContainer</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NorthwindEntities</span>"<span style="color: blue;"> </span><span style="color: red;">EntitySet</span><span style="color: blue;">=</span>"<span style="color: blue;">OrderDetails</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Parameter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">Name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Oid</span>"<span style="color: blue;"> </span><span style="color: red;">Type</span><span style="color: blue;">=</span>"<span style="color: blue;">Int32</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Function</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />This metadata is similar to our previous example.<span style="mso-spacerun: yes;">&nbsp; </span>However, when mapping to Entity types, we must list two additional properties in our Function node: an EntityContainer and an EntitySet.<span style="mso-spacerun: yes;">&nbsp; </span>These two values must refer to existing artifacts in the conceptual layer.<br /><br /><br /><br /><o:p></o:p></span></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;">Object Layer</b><br />Here is our function stub for a TVF&rsquo;s result set mapped to a collection of Entity Types:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 2.5pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.14%; padding-right: 5.4pt; height: 2.5pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.86%; padding-right: 5.4pt; height: 2.5pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">EdmFunction</span>(<span style="color: #a31515;">"NorthwindModel"</span>, <span style="color: #a31515;">"GetDetailsForOrderAsEntity"</span>)]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">IQueryable</span>&lt;<span style="color: #2b91af;">OrderDetails</span>&gt; GetDetailsForOrderAsEntity(<span style="color: blue;">int</span> Oid)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> <span style="color: blue;">this</span>.CreateQuery&lt;<span style="color: #2b91af;">OrderDetails</span>&gt;(<span style="color: #a31515;">"[NorthwindModel].[GetDetailsForOrderAsEntity](@Oid)"</span>,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>new</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">ObjectParameter</span>(<span style="color: #a31515;">"Oid"</span>, Oid));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><b style="mso-bidi-font-weight: normal;"><br /><br />Usage<br /></b>With our mapping in place, we can begin using our Entities in the usual fashion. <span style="mso-spacerun: yes;">&nbsp;</span>In the following example we will call our TVF and do some simple update to the resulting Entities:<br /><br /><o:p></o:p></span></span></span></p>
<table cellpadding="0" cellspacing="0" border="1" class="MsoTableGrid" style="width: 100%; border-collapse: collapse; background: #f3ffff; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr style="height: 27.4pt; mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes;">
<td width="4%" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 4.82%; padding-right: 5.4pt; height: 27.4pt; padding-top: 0in; mso-border-alt: solid windowtext .5pt; border: windowtext 1pt solid;">
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">1.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">3.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">4.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">5.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">6.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">7.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">8.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">9.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">10.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">11.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">12.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">13.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">14.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">15.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">16.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">17.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">18.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">19.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">20.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">21.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">22.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">23.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt; mso-no-proof: yes;">24.<o:p></o:p></span></p>
</td>
<td width="95%" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 95.18%; padding-right: 5.4pt; height: 27.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;">
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">var</span> context = <span style="color: blue;">new</span> <span style="color: #2b91af;">NorthwindEntities</span>())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//</span></span><span style="font-family: Segoe UI; font-size: x-small;"> </span><span style="font-family: Consolas; color: green; font-size: 9.5pt;">Use GetDetailsForOrderAsEntity with LINQ and update entities using ObjectContext<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">var</span> OrderDetails = <span style="color: blue;">from</span> OrderDetail <span style="color: blue;">in</span> context.GetDetailsForOrderAsEntity(10248)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">where</span> OrderDetail.Quantity &gt; 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">select</span> OrderDetail;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> item <span style="color: blue;">in</span> OrderDetails)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"[{0}] {1} &ndash; Original Quantity={2}"</span>,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>item.OrderID, item.ProductID, item.Quantity);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>item.Quantity = 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>context.SaveChanges();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>OrderDetails = <span style="color: blue;">from</span> OrderDetail <span style="color: blue;">in</span> context.GetDetailsForOrderAsEntity(10248)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">select</span> OrderDetail;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"New Values"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> item <span style="color: blue;">in</span> OrderDetails)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"[{0}] {1} &ndash; New Quantity={2}"</span>,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>item.OrderID, item.ProductID, item.Quantity);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;"><br /><br />In this example we get the products in Order #10248 with a quantity greater than 1. <span style="mso-spacerun: yes;">&nbsp;</span>Then we change each quantity to 1.<span style="mso-spacerun: yes;">&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;</span>The important thing to note about this scenario is that we were able to query for a specific set of order details &ndash;those with a quantity greater than 1&mdash;using a TVF.<span style="mso-spacerun: yes;">&nbsp; </span>Then we edited the resulting entities to which the TVFs result set was mapped.<br /><br /><o:p></o:p></span></span></span></p>
<h1 style="margin: 12pt 0in 0pt;"><span style="font-size: medium;"><span style="color: #365f91;"><span style="font-family: Segoe UI;">Wrap-Up<o:p></o:p></span></span></span></h1>
<p class="MsoNormal"><span style="font-family: Segoe UI;"><span style="font-size: small;">In this article we have covered:<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Background on TVFs in SQL<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Calling a TVF directly from a LINQ or Entity SQL query<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Metadata for mapping a collection of Complex Type to a TVF, and subsequent usage<o:p></o:p></span></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-size: small;"><span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">&middot;<span style="line-height: normal; font-variant: normal; font-style: normal; font-family: 'Times New Roman'; font-weight: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: Segoe UI;">Metadata for mapping a collection of Entity Type to a TVF, and subsequent usage including CUD<br /><br /><o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: x-small;"><span style="font-family: Segoe UI;"><span style="font-size: small;">TVF support will be a key component of Entity Framework&rsquo;s next release.<span style="mso-spacerun: yes;">&nbsp; </span>Our goal is to provider first-class support for TVFs by allowing users to map the function&rsquo;s result set to Entity types and Complex types. <span style="mso-spacerun: yes;">&nbsp;</span>We look forward to getting your feedback, so feel free to make any comments or ask questions about this design.<br /><br /><o:p></o:p></span></span></span></p>
<p><span style="line-height: 115%; font-family: 'Segoe UI','sans-serif'; mso-fareast-font-family: Calibri; mso-bidi-font-size: 11.0pt; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><span style="font-size: small;">Pedro Ardila<br />Program Manager <br />ADO.Net Entity Framework Team</span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Code First Database Evolution (aka Migrations)</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/code-first-database-evolution-aka-migrations</link>
      <pubDate>Fri, 22 Oct 2010 14:42:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2010/10/22/code-first-database-evolution-aka-migrations/</guid>
      <description><![CDATA[Back in July we released the latest preview of Code First and we&rsquo;ve been receiving a lot of...]]></description>
      <content:encoded><![CDATA[<p>Back in July we released the <a href="https://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4announcement.aspx">latest preview of Code First</a> and we&rsquo;ve been receiving a lot of feedback that is helping us shape this feature. One of the top asks we are hearing is for a solution that will evolve the database schema as your object model changes over time, often referred to as migrations.&nbsp;</p>
<p>Our team is looking at a few different options in this area and we really want to get your feedback on one of the options we are considering that takes a somewhat different approach to most existing migration solutions.&nbsp;</p>
<p>We&rsquo;ve put together a screen cast to walk you through a storyboard style mock-up we built that shows this solution being used to build and deploy an application. We really want your feedback to help us shape and evaluate this option, you can provide feedback using the comment functionality on this post.&nbsp;</p>
<p>This is the first time our team has used a storyboard screencast to share proposed designs so we&rsquo;d also love to hear your feedback on whether this is an effective way to share our ideas.&nbsp;</p>
<p>ADO.NET Entity Framework Team</p>
<p>&nbsp;</p>
<p><span style="color: #ff0000;">(HD option is available in lower right corner of player while the screencast is playing)</span></p>
<p><iframe type="text/html" width="550" frameborder="0" src="https://www.youtube.com/embed/tImrLkaxXpI?hd=1" height="420" title="Screencast" class="youtube-player"></iframe></p>]]></content:encoded>
    </item>
    <item>
      <title>Entity Designer Improvements Preview</title>
      <link>https://docs.microsoft.com/archive/blogs/efdesign/entity-designer-improvements-preview</link>
      <pubDate>Mon, 11 Oct 2010 16:13:00 GMT</pubDate>
      <dc:creator><![CDATA[dpblogs]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/efdesign/2010/10/11/entity-designer-improvements-preview/</guid>
      <description><![CDATA[The team has been quietly working on a number of improvements to the entity designer that we would...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">The team has been quietly working on a number of improvements to the entity designer that we would like to show off and get feedback on. This particular set of features is targeted at making modeling more productive and scalable, and models themselves more comprehensible.</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span><span style="font-size: small;"><span style="font-family: Calibri;"><br />We&rsquo;ll start with the small, fun things, and build up to a grand finale.</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;"></span></o:p></p>
<p class="MsoNormal"><b><span style="font-size: small;"><span style="font-family: Calibri;"><br />1. Association Highlighting<o:p></o:p></span></span></b></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;"></span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Let&rsquo;s start with this. Consider the following model:<br /><br /><br /></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"><v:shapetype coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f" id="_x0000_t75">&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/4578.AssociationHighlighting.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/4578.AssociationHighlighting.jpg" border="0" /><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype></span></span></span></p>
<p><span style="font-family: Calibri;"></span></p>
<p class="MsoNormal"><span style="font-size: small;">We would like to rename the navigation properties to something meaningful, as well as the foreign keys. But which navigation property is related to which foreign key? And to which association connector?<br /><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: small;"><br />So, now you can select an association or navigation property and find out. Here, we select the &ldquo;Address.Person&rdquo; navigation property, and the designer highlights the two entity types involved in the association, the association connector, the navigation property on the other side, as well as the foreign keys that hold the navigation information.<o:p></o:p></span></p>
<p>&nbsp;</p>
<p>
<p class="MsoNormal">&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/2664.AssociationHighlighting2.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/2664.AssociationHighlighting2.jpg" border="0" /></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">This makes it easier for us to rename things to:</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri; font-size: small;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/3122.AssociationHighlighting3.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/3122.AssociationHighlighting3.jpg" border="0" /></span></p>
<p class="MsoNormal"><span style="font-family: Calibri; font-size: small;"></span></p>
<p class="MsoNormal"><span style="font-family: Calibri; font-size: small;"></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span>&nbsp;</p>
<p><span style="font-size: small;"><span style="font-family: Calibri;"></span></span></p>
<p class="MsoNormal"><b>2. Property Reordering<o:p></o:p></b></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Imagine that you want to add a &ldquo;Name&rdquo; property to the &ldquo;Property&rdquo; type above. You do this and end up with a type that looks like this:</p>
<p class="MsoNormal">&nbsp;</p>
</p>
<p class="MsoNormal">&nbsp;<img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/7534.PropertyReordering.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/7534.PropertyReordering.jpg" border="0" /></p>
<p>
<p class="MsoNormal">&nbsp;<span style="font-size: small;"><span style="font-family: Calibri;">But of course, you want this new property to be the second one in the type, below &ldquo;Id&rdquo;. Well, now you can select this property and, for example, press Alt + Home, which will move that property to the top of the type, then on Alt + Down Arrow to move it down one slot. Here is a screenshot of the type, along with the new &ldquo;Move Properties&rdquo; menu:</span></span></p>
</p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/3833.PropertyReordering2.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/3833.PropertyReordering2.jpg" border="0" /></o:p></span></span></p>
<p class="MsoNormal"><o:p><br />You can now select multiple properties at the same time and move them.&nbsp; For example:<br /></o:p></p>
<p class="MsoNormal"><o:p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/1777.PropertyReordering3.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/1777.PropertyReordering3.jpg" border="0" /></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p><o:p>
<p class="MsoNormal"><b><span style="font-size: small;"><span style="font-family: Calibri;"><br />3. Entity Shape Coloring<o:p></o:p></span></span></b></p>
<p class="MsoNormal"><b><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></b><span style="font-size: small;"><span style="font-family: Calibri;">Imagine, now, that our model has gotten more complex, and viewing it all in one window renders areas of the diagram hard to distinguish:</span></span></p>
</o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/4237.EntityShapeColoring.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/4237.EntityShapeColoring.jpg" border="0" /></o:p></span></span></p>
<p>
<p class="MsoNormal">&nbsp;</p>
</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Entity shape coloring allows us to visually divide a single diagram into multiple meaningful areas by color coding them. You can select one or more entities and in their property sheet, change their color, which lets us do something like this:<br /><br /><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/0841.EntityShapeColoring2.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/0841.EntityShapeColoring2.jpg" border="0" /><br /></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span></p>
<p><o:p>
<p class="MsoNormal"><b><span style="font-size: small;"><span style="font-family: Calibri;">4. Multiple Diagrams<span style="color: #1f497d;">!</span><o:p></o:p></span></span></b></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">But what if you just want to look at subject areas within a diagram? Say, the product catalog entities, or the sales types. In that case, you can select any number of entities and move them into a new diagram by right-clicking and selecting the new &ldquo;Move to new Diagram&rdquo; menu item. If we do this to our &ldquo;Property&rdquo; type, we&rsquo;ll see it appear in a new </span></span><span style="font-size: small;"><span style="font-family: Calibri;">diagram. And, if we make the model browser tool window visible, we&rsquo;ll see this:</span></span></p>
</o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/7635.MultipleDiagrams.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/7635.MultipleDiagrams.jpg" border="0" /></o:p></span></span></p>
<p>
<p>&nbsp;</p>
</p>
<p>&nbsp;</p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Note that we now have a new &ldquo;Diagrams&rdquo; folder in the model browser, and that the new diagram opens in its own tab, allowing you to have multiple windows open at once against the same model. This diagram is a little sparse. Let&rsquo;s bring into it any types related to &ldquo;Property&rdquo; by right-clicking it and selecting &ldquo;Include Related&rdquo;:</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/1200.MultipleDiagrams2.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/1200.MultipleDiagrams2.jpg" border="0" /></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p></o:p></span></span></p>
<p><span style="font-size: small;"><span style="font-family: Calibri;"><o:p>
<p class="MsoNormal">Now, color the &ldquo;Person&rdquo; type green, then bring its related type, and see how they pick up the original type&rsquo;s color:</p>
<p class="MsoNormal">&nbsp;</p>
</o:p></span></span>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"><o:p></o:p></span></span></p>
</p>
<p class="MsoNormal"><o:p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/06/61/4035.MultipleDiagrams3.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-06-61/4035.MultipleDiagrams3.jpg" border="0" /></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p><o:p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">(Note that this models is not a real-world one and only intended for visualization purposes.)<o:p></o:p></span></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Some additional notes:<o:p></o:p></span></span></p>
<p class="MsoListParagraph"><span style="font-family: Calibri; font-size: small;">-</span><span style="font-family: 'Times New Roman','serif'; font-size: 7pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: small;"><span style="font-family: Calibri;">You can also drag and drop associations, types, and entity sets from the model browser.<o:p></o:p></span></span></p>
<p class="MsoListParagraph"><span style="font-family: Calibri; font-size: small;">-</span><span style="font-family: 'Times New Roman','serif'; font-size: 7pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: small;"><span style="font-family: Calibri;">You can cut or copy and paste objects from one diagram to another.<o:p></o:p></span></span></p>
<p class="MsoListParagraph"><span style="font-family: Calibri; font-size: small;">-</span><span style="font-family: 'Times New Roman','serif'; font-size: 7pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: small;"><span style="font-family: Calibri;">Deleting objects from a diagram will no longer delete them from the model, but only from the diagram.<o:p></o:p></span></span></p>
<p class="MsoListParagraph"><span style="font-family: Calibri; font-size: small;">-</span><span style="font-family: 'Times New Roman','serif'; font-size: 7pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: small;"><span style="font-family: Calibri;">You can delete objects from the model by using Shift+Del, right clicking and selecting &ldquo;Delete from Model&rdquo;, or deleting them from the model browser.<o:p></o:p></span></span></p>
<p class="MsoListParagraph"><span style="font-family: Calibri; font-size: small;">-</span><span style="font-family: 'Times New Roman','serif'; font-size: 7pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: small;"><span style="font-family: Calibri;">Diagrams are stored in a child file of the edmx for new edmx files. For backwards compatibility, models created in previous versions of visual studio will keep the diagram information in the EDMX file itself. However, you can move the diagram information from the EDMX to a child file by right clicking and selecting the &ldquo;Move Diagrams to Separate File&rdquo; context menu.<o:p></o:p></span></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">We look forward to your feedback!<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">&nbsp; Noam<o:p></o:p></span></span></p>
<p class="MsoNormal">&nbsp;</p>
</o:p></p>
<p class="MsoNormal">&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>