<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.bartdesmet.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">LINQ to SharePoint</title><subtitle type="html">Tales from the LINQ to SharePoint team</subtitle><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20423.869">Community Server</generator><updated>2007-07-03T01:00:52Z</updated><entry><title>Now available: 0.2.4.0 alpha for Orcas RTM</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/11/30/now-available-0-2-4-0-alpha-for-orcas-rtm.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/11/30/now-available-0-2-4-0-alpha-for-orcas-rtm.aspx</id><published>2007-11-30T08:27:02Z</published><updated>2007-11-30T08:27:02Z</updated><content type="html">&lt;p&gt;It&amp;#39;s finally here: &lt;strong&gt;&lt;a href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=LINQtoSharePoint&amp;amp;ReleaseId=8713"&gt;LINQ to SharePoint 0.2.4.0 Alpha&lt;/a&gt;&lt;/strong&gt;. This is our first official release &lt;strong&gt;targeting Visual Studio 2008 and .NET Framework 3.5 RTM&lt;/strong&gt;.    &lt;br /&gt;&lt;/p&gt;  &lt;h1&gt;What&amp;#39;s new in this release?&lt;/h1&gt;  &lt;p&gt;The focus for this release was primarily on getting the bits ready for &lt;strong&gt;Visual Studio 2008 RTM&lt;/strong&gt;. Although there were no major API changes between Orcas Beta 2 and Orcas RTM that affected LINQ to SharePoint, we needed to validate quite some things.&lt;/p&gt;  &lt;p&gt;While working on entity updating support in a separate prototyping branch (something planned for v0.3, which will be our first Beta, planning TBD) a few &lt;strong&gt;bug fixes&lt;/strong&gt; made it in this alpha.&lt;/p&gt;  &lt;p&gt;One major point of focus was reducing the dependencies by introducing a &lt;strong&gt;provider model&lt;/strong&gt;. In the past alphas, there was a strong dependency on Microsoft.SharePoint, aka the SharePoint Object Model. Normally, this assembly is only available on machines where Windows SharePoint Services is installed. Using LINQ to SharePoint previously introduced the need to redistribute this assembly because:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;we had a few internal dependencies on it in the parser;&lt;/li&gt;    &lt;li&gt;the generated data context object had a constructor taking in an SPSite object.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;First of all, we eliminated the dependencies in the parser, making the parser &amp;quot;provider-agnostic&amp;quot;. Next, the communication layer was divided into two pieces:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;a webservice based provider, which is integrated in BdsSoft.SharePoint.Linq;&lt;/li&gt;    &lt;li&gt;a SharePoint Object Model based provider, that lives in a separate assembly called BdsSoft.SharePoint.Linq.ObjectModelProvider.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;By default, we only import BdsSoft.SharePoint.Linq which uses webservice communication and doesn&amp;#39;t depend on Microsoft.SharePoint. If you want to use the SharePoint Object Model you&amp;#39;ll need to opt-in for it explicitly. Since the SharePoint Object Model can be used only on the local machine where WSS is installed, you&amp;#39;ll have the Microsoft.SharePoint assembly over there anyhow.&lt;/p&gt;  &lt;p&gt;The way this looks in the Entity Wizard is shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="480" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_thumb.png" width="570" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This checkbox has to be explicitly marked if you want to use the SharePoint Object Model. It causes the SPML to include an attribute that switches on the SharePoint Object Model data provider (click to enlarge):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="272" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_thumb_1.png" width="1024" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When generating the code for the SPML definition, we&amp;#39;ll emit an additional constructor that supports the SharePoint Object Model (click to enlarge):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_12.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="556" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_thumb_5.png" width="1024" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Under the covers, the SharePointDataContext base class has a constructor overload accepting a Uri (for the web services provider which comes with the LINQ to SharePoint main assembly) and one that takes in an ISharePointDataProvider, a new interface that abstracts away the underlying provider implementation. Theoretically 3rd parties could implement another provider but the Entity Generator tool won&amp;#39;t be aware of it (theoretically we could have provider registration stuff in the registry and load the provider list dynamically, asking it to generate the desired constructor overloads, etc but we don&amp;#39;t expect there&amp;#39;s a big need for additional providers - tell us if the assumption is wrong!).&lt;/p&gt;  &lt;p&gt;Only if the SharePoint Object Model provider was enabled, we&amp;#39;ll import the required assemblies for you:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="226" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_thumb_3.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice our setup package that integrates with Visual Studio 2008 includes these assemblies but the goal of this feature is to reduce the runtime (and deployment) dependencies.&lt;/p&gt;  &lt;p&gt;For the SPMetal freaks we have an -enablesom flag that does exactly the same as the wizard:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="480" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Nowavailable0.2.4.0alphaforOrcasRTM_667/image_thumb_4.png" width="549" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h1&gt;Download now&lt;/h1&gt;  &lt;p&gt;Get it here: &lt;strong&gt;&lt;a href="https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=LINQtoSharePoint&amp;amp;ReleaseId=8713"&gt;LINQ to SharePoint 0.2.4.0 Alpha&lt;/a&gt;&lt;/strong&gt;. &lt;font color="#ff0000"&gt;Notice all usual disclaimers apply; this software is still alpha quality so we don&amp;#39;t make any guarantees whatsoever concerning the functional or quality.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12902" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Releases" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Releases/default.aspx" /></entry><entry><title>LINQ to SharePoint 0.2.4.0 Alpha for Orcas RTM is here</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/11/29/linq-to-sharepoint-0-2-4-0-alpha-for-orcas-rtm-is-here.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/11/29/linq-to-sharepoint-0-2-4-0-alpha-for-orcas-rtm-is-here.aspx</id><published>2007-11-30T00:19:00Z</published><updated>2007-11-30T00:19:00Z</updated><content type="html">&lt;p&gt;I&amp;#39;m happy to announce you the availability of LINA to SharePoint 0.2.4.0 Alpha, ready for VS2008 and .NET Framework 3.5 RTM. &lt;a class="" href="http://community.bartdesmet.net/blogs/linqtosharepoint/archive/2007/11/30/now-available-0-2-4-0-alpha-for-orcas-rtm.aspx"&gt;Read the full details on the LINQ to SharePoint team blog.&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12905" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="LINQ" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/LINQ/default.aspx" /></entry><entry><title>New blog series on LINQ to SharePoint</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/08/22/new-blog-series-on-linq-to-sharepoint.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/08/22/new-blog-series-on-linq-to-sharepoint.aspx</id><published>2007-08-22T10:46:09Z</published><updated>2007-08-22T10:46:09Z</updated><content type="html">&lt;p&gt;Dimitri Clement has jumped on the LINQ to SharePoint trained and started a blog series on using LINQ to SharePoint. His first entry can be found on his blog &lt;a href="http://technoblogy.spaces.live.com/blog/cns!29F7CF27A98D236F!274.entry" target="_blank"&gt;over here&lt;/a&gt;. In his entry, he outlines the installation of the 0.2.3 build and how to get a jumpstart with LINQ to SharePoint. Enjoy and keep an eye on his blog for more posts in the near future!&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12677" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author></entry><entry><title>Alpha 0.2.3 now available</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/08/13/alpha-0-2-3-now-available.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/08/13/alpha-0-2-3-now-available.aspx</id><published>2007-08-13T21:00:49Z</published><updated>2007-08-13T21:00:49Z</updated><content type="html">&lt;p&gt;Last weekend, we did the finishing touch on the 0.2.3 release, so here it is today: please welcome &lt;a href="http://www.codeplex.com/LINQtoSharePoint/Release/ProjectReleases.aspx?ReleaseId=6400" target="_blank"&gt;LINQ to SharePoint v0.2.3.0 alpha&lt;/a&gt;. This is the first release to target &lt;strong&gt;Orcas Beta 2&lt;/strong&gt; and covers the following enhancements:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;SPML&lt;/strong&gt; has been extended and can now map lists, fields and choices on (Multi)Choice fields. The LINQ to SharePoint MSI setup registers the &lt;strong&gt;XSD&lt;/strong&gt; file for SPML in the appropriate folder so you get full &lt;strong&gt;IntelliSense&lt;/strong&gt; support in the VS IDE.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_1.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="123" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_1.png" width="240" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Also, the code generator sitting behind the SPML files in VS 2008 doesn&amp;#39;t require any connection to the server when generating code since SPML is now fully self-describing. As a matter of fact, the SPML code generator runs in so-called &amp;quot;offline codegen&amp;quot; mode, as explained further in the SPMetal section.&lt;br /&gt; &lt;li&gt;The &lt;strong&gt;LINQ to SharePoint Entity Wizard&lt;/strong&gt; is fully layered on top of the entity generator and supports enhanced list and field mapping (including the ability to set aliases on mappings to make the generated classes more user-friendly). It also support list name (English) depluralization (see below):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb9.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="220" alt="image_thumb9" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb9_thumb.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="173" alt="image_thumb10" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb10_thumb.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb12.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="159" alt="image_thumb12" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb12_thumb.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb13.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="159" alt="image_thumb13" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb13_thumb.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt; &lt;li&gt;&lt;strong&gt;SPMetal&lt;/strong&gt; enhancements:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb14.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="200" alt="image_thumb14" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb14_thumb.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt; &lt;ul&gt; &lt;li&gt;Full support for SPML using two times two modi: online and offline; export and codegen (but offline-export isn&amp;#39;t meaningful). So you can do things like this:  &lt;ul&gt; &lt;li&gt;Online - export: generate an SPML file for the specified list + optional context  &lt;li&gt;Online - codegen: generates C# or VB code for the specified list + optional context (internally, it first generates the corresponding SPML)  &lt;li&gt;Offline - codegen: takes an SPML file as the input and generates C# or VB code for it; this allows people to export SPML first (online-export), modify it and then generate code out of it&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;List name (English) depluralization. E.g. a list called Products will create an entity called Product, a list called Categories will create an entity called Category, etc.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;Partial method&lt;/strong&gt; support for entity properties on generated entities, both for C# and VB:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="159" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_2.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;This feature will get more important once we move in the 0.3 timeframe where entity updates will be supported.&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Grouping&lt;/strong&gt; support; you can now write things like:&lt;br /&gt;&lt;br /&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt; res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Suppliers &lt;font color="#0000ff"&gt;group &lt;/font&gt;s &lt;font color="#0000ff"&gt;by &lt;/font&gt;s.Country;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;-or-&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Suppliers &lt;font color="#0000ff"&gt;group &lt;/font&gt;s &lt;font color="#0000ff"&gt;by &lt;/font&gt;s.Country&amp;nbsp;&lt;font color="#0000ff"&gt;into &lt;/font&gt;g &lt;font color="#0000ff"&gt;select &lt;/font&gt;g;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;and iterate over the results as follows:&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;foreach &lt;/font&gt;(&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;g &lt;font color="#0000ff"&gt;in &lt;/font&gt;res)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(g.Key ?? &lt;font color="#800000"&gt;&amp;quot;(null)&amp;quot;&lt;/font&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;foreach &lt;/font&gt;(&lt;font color="#0000ff"&gt;var &lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;g)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;- {0}&amp;quot;&lt;/font&gt;, s.CompanyName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb18.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="154" alt="image_thumb18" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb18_thumb.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb16.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image_thumb16" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb16_thumb.png" width="240" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Trebuchet MS"&gt;Furthermore, we&amp;#39;re working on &lt;strong&gt;making the parser more intelligent&lt;/strong&gt;. That&amp;#39;s the case with grouping support as well (and it&amp;#39;s the first place where you can see it in action), more specifically when using the IGrouping&amp;lt;K,T&amp;gt;&amp;#39;s Key as follows:&lt;br /&gt;&lt;/font&gt;&lt;/li&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Suppliers &lt;font color="#0000ff"&gt;group &lt;/font&gt;s &lt;font color="#0000ff"&gt;by &lt;/font&gt;s.Country&amp;nbsp;&lt;font color="#0000ff"&gt;into &lt;/font&gt;g &lt;font color="#0000ff"&gt;select &lt;/font&gt;g.Key;&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Trebuchet MS"&gt;This will return the keys of the grouping, in this case all of the countries where some supplier is based. If you&amp;#39;d inspect this query using the debugger visualizer, you&amp;#39;d see that only the Country list field will be present in the query&amp;#39;s ViewFields element. Because g.Key can only&amp;nbsp;refer to the &amp;#39;by&amp;#39;-part of the corresponding grouping operation, the parser can infer the meaning of g.Key. In the future you&amp;#39;ll probably see more intelligende get built-in in the parser, but some of that development is done in parallel in an experimental code branch.&lt;/font&gt;&lt;font face="Trebuchet MS"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/font&gt; &lt;li&gt;&lt;strong&gt;Nested Lookup field subqueries&lt;/strong&gt;: in the past you could write things like this:&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Products&amp;nbsp;&lt;font color="#0000ff"&gt;where&amp;nbsp;&lt;/font&gt;p.Category.CategoryName == &lt;font color="#800000"&gt;&amp;quot;Beverages&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#0000ff"&gt;select &lt;/font&gt;p;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;However, assume you have another list that contains orders, so you&amp;#39;d like to query for all of the orders of products in some category:&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;o &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Orders&amp;nbsp;&lt;font color="#0000ff"&gt;where&amp;nbsp;&lt;/font&gt;o.Product.Category.CategoryName == &lt;font color="#800000"&gt;&amp;quot;Beverages&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#0000ff"&gt;select &lt;/font&gt;o;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;This didn&amp;#39;t work in previous builds, but it does now. However, one should be vigilant when writing such queries because of the imposed runtime overhead. The query above will cause three roundtrips to the server because of CAML restrictions that are overcome by the query parser using a patching mechanism (see &lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/10/lookup-fields-inside-out.aspx" target="_blank"&gt;previous post on Lookup fields&lt;/a&gt;). Now we can have nested patches that are run in a depth-first manner. The code above is translated into the following query:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="213" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_4.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;So, first the execution engine will go out to the server to get all of the categories that have a CategoryName equal to &amp;quot;Beverages&amp;quot;. Once we&amp;#39;ve obtained the IDs for those categories, we replace the patch (&amp;lt;Patch Field=&amp;quot;Category&amp;quot;&amp;gt;) with a nested &amp;lt;Or&amp;gt; structure to select all of the products that match these categories. On its turn, this result is substituted in the original query as a replacement for the corresponding patch (&amp;lt;Patch Field=&amp;quot;Product&amp;quot;&amp;gt;). As you can imagine, these queries can get pretty large before we get to the stage of retrieving the actual query results. Nevertheless, there&amp;#39;s no easier escape in SharePoint to do this. Here&amp;#39;s the &amp;quot;query plan&amp;quot; for the query above:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_6.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="60" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_6.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_7.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="59" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_7.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_8.png" width="159" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;There&amp;#39;s much more to nested lookup field subqueries than you might initially think. For example, consider the query below:&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;o &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Orders&amp;nbsp;&lt;font color="#0000ff"&gt;where&amp;nbsp;&lt;/font&gt;o.Product.Supplier.Country == &lt;font color="#800000"&gt;&amp;quot;USA&amp;quot;&lt;/font&gt;&amp;nbsp;&amp;amp;&amp;amp; o.Product.Supplier.Region == &lt;font color="#800000"&gt;&amp;quot;WA&amp;quot;&lt;/font&gt; &amp;amp;&amp;amp; o.Product.ProductName.StartsWith(&lt;font color="#800000"&gt;&amp;quot;Ch&amp;quot;&lt;/font&gt;) &lt;font color="#0000ff"&gt;select &lt;/font&gt;o;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;In a naive query parser implementation you&amp;#39;d end up with as much as five patches, so a total of six roundtrips to the server:&lt;br /&gt;&lt;br /&gt;&amp;lt;And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Patch Field=&amp;quot;Product&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Patch Field=&amp;quot;Supplier&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Country&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;USA&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Patch&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Patch&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Patch Field=&amp;quot;Product&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Patch Field=&amp;quot;Supplier&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Region&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;WA&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Patch&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Patch&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/And&amp;gt;&lt;/li&gt;&amp;nbsp;&amp;nbsp; &amp;lt;Patch Field=&amp;quot;Product&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;ProductName&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;Ch&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/Patch&amp;gt;&lt;br /&gt;&amp;lt;/And&amp;gt;&lt;br /&gt;&lt;br /&gt;Luckily, there parser is made more intelligent than this because it can join adjacent query predicate patches, resulting in this:&lt;br /&gt;&lt;br /&gt;&amp;lt;Patch Field=&amp;quot;Product&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Patch Field=&amp;quot;Supplier&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Country&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;USA&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;State&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;WA&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;/And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Patch&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;ProductName&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;Ch&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/And&amp;gt;&lt;br /&gt;&amp;lt;/Patch&amp;gt;&lt;br /&gt;&lt;br /&gt;This is only two patches, instead of the naive five:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_9.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_9.png" width="212" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;As a side-note, a future build will cover &lt;em&gt;parser warnings&lt;/em&gt; that will show possible bottlenecks (as well as semantic mismatches) in the debugger visualizer. It will also be possible to control the parser&amp;#39;s intelligence and to do a radical &amp;quot;treat warnings as errors&amp;quot;&amp;nbsp;because the more intelligent some features, the more expensive these might be.&lt;br /&gt;&lt;br /&gt; &lt;li&gt;(Nested) &lt;strong&gt;LookupMulti subqueries&lt;/strong&gt; are now supported too. In the sample above, we assumed that each of the orders in the Orders list just contains one single product reference. Of course, one might have a list that has a &amp;quot;multi lookup&amp;quot; column that refers to multiple items from another list (e.g. more than one product). Assume you have such an Orders list and you want to get all of the orders that have a product from a certain category in it:&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;o &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Orders &lt;font color="#0000ff"&gt;where&amp;nbsp;&lt;/font&gt;o.Products.Any(p =&amp;gt; p.Category.CategoryName == &lt;font color="#800000"&gt;&amp;quot;Beverages&amp;quot;&lt;/font&gt;) &lt;font color="#0000ff"&gt;select &lt;/font&gt;o;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;In here, the Any call - which is an extension method on System.Linq.Enumerable - is crucial because it&amp;#39;s used as the only mechanism available to pass in a subquery predicate, in this case applied to the Products field. Again, this works with patches:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="204" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Alpha0.2.3nowavailable_123A0/image_thumb_10.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;In this sample, the inner patch is corresponding to the subquery&amp;#39;s p.Category.CategoryName Lookup field traversal, and the outer patch corresponds to the outer query&amp;#39;s o.Products.Any call. Notice, for these kind of lookup-related constructs,&amp;nbsp;an alternative implementation could be using joins but we don&amp;#39;t have these in LINQ to SharePoint (at least not) at the moment.&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Debugger visualizer&lt;/strong&gt; improvements were made behind the scenes but also auto-linkage to Online F1 help information has been added: so, if you have a query problem right now, you&amp;#39;ll be able to click on the SP**** error message and get help in the Document Explorer. However, notice that at this moment the help and documentation project is not integrated in the build yet, so you&amp;#39;ll stumble upon invalid help documentation links in this build.&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Code quality&lt;/strong&gt; improvements thanks to extended coverage by code analysis and use of additional FxCop rules. However, unit test coverage is to be extended further in subsequent releases, which is a top priority in moving forward to the 0.3 timeframe. Furthermore, the code has been refactored into &lt;strong&gt;additional assemblies&lt;/strong&gt;, e.g. for the debugger visualizer, to reduce the runtime workingset. In a subsequent release, the &lt;strong&gt;provider model&lt;/strong&gt; will be enhanced so that people who want to use LINQ to SharePoint over web services alone don&amp;#39;t require Microsoft.SharePoint.dll on their machine (the reason for this right now is that we depend on a few parse methods from the SharePoint Object Model, but we&amp;#39;ll port these to be natively supported by LINQ to SharePoint).&lt;br /&gt;&lt;/li&gt; &lt;li&gt;The &lt;strong&gt;MSI Setup&lt;/strong&gt; has improved much:&lt;/li&gt; &lt;ul&gt; &lt;li&gt;it&amp;#39;s faster because we reconfigure Visual Studio 2008 in a different way&lt;/li&gt; &lt;li&gt;it registers the XSD schema of SPML&lt;/li&gt; &lt;li&gt;the .spml extension is registered with an icon and linking to devenv.exe&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;p&gt;We hope you&amp;#39;ll enjoy this release; keep in mind it&amp;#39;s still alpha and send us your suggestions, comments, etc. &lt;a href="http://www.codeplex.com/LINQtoSharePoint/Release/ProjectReleases.aspx?ReleaseId=6400" target="_blank"&gt;Get it here.&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12661" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Releases" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Releases/default.aspx" /></entry><entry><title>LINQ to SharePoint ready for Orcas Beta 2</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/08/01/linq-to-sharepoint-ready-for-orcas-beta-2.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/08/01/linq-to-sharepoint-ready-for-orcas-beta-2.aspx</id><published>2007-08-02T00:09:36Z</published><updated>2007-08-02T00:09:36Z</updated><content type="html">&lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_1.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="100" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_1.png" width="153" align="right" border="0" /&gt;&lt;/a&gt; Last week, Microsoft shipped Orcas Beta 2; today, the Visual Studio SDK that goes with it was released as well. Ready for us to move LINQ to SharePoint to Orcas Beta 2. More specifically, the query provider core was changed slightly to adapt the new IQueryProvider/IQueryable interface split and a few adjustments were made concerning Visual Studio 2008 integration. If you can&amp;#39;t wait any longer, you can download the latest sources over &lt;a href="http://www.codeplex.com/LINQtoSharePoint/SourceControl/ListDownloadableCommits.aspx" target="_blank"&gt;here&lt;/a&gt;. Or just wait another few days for a new release that targets Orcas Beta 2 together with some new features.&lt;/p&gt; &lt;p&gt;What can you expect from the next interim release?&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;SPML&lt;/strong&gt; has been extended and can now map lists, fields and choices on (Multi)Choice fields.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="148" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_2.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;/li&gt; &lt;li&gt;The &lt;strong&gt;LINQ to SharePoint Entity Wizard&lt;/strong&gt; is fully layered on top of the entity generator and supports enhanced list and field mapping (including the ability to set aliases on mappings to make the generated classes more user-friendly). It also support list name (English) depluralization (see below):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="220" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_4.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_5.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="173" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_5.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_7.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="159" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_7.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="159" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_8.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;SpMetal&lt;/strong&gt; enhancements:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_9.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="200" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_9.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;/li&gt; &lt;ul&gt; &lt;li&gt;Full support for SPML using two times two modi: online and offline; export and codegen (but offline-export isn&amp;#39;t meaningful). So you can do things like this:&lt;/li&gt; &lt;ul&gt; &lt;li&gt;Online - export: generate an SPML file for the specified list + optional context&lt;/li&gt; &lt;li&gt;Online - codegen: generates C# or VB code for the specified list + optional context (internally, it first generates the corresponding SPML)&lt;/li&gt; &lt;li&gt;Offline - codegen: takes an SPML file as the input and generates C# or VB code for it; this allows people to export SPML first (online-export), modify it and then generate code out of it&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;List name (English) depluralization. E.g. a list called Products will create an entity called Product, a list called Categories will create an entity called Category, etc.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;Grouping&lt;/strong&gt; support. That&amp;#39;s right, you can now write things like:&lt;br /&gt;&lt;br /&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt; res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Suppliers &lt;font color="#0000ff"&gt;group &lt;/font&gt;s &lt;font color="#0000ff"&gt;by &lt;/font&gt;s.Country;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;-or-&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Suppliers &lt;font color="#0000ff"&gt;group &lt;/font&gt;s &lt;font color="#0000ff"&gt;by &lt;/font&gt;s.Country&amp;nbsp;&lt;font color="#0000ff"&gt;into &lt;/font&gt;g &lt;font color="#0000ff"&gt;select &lt;/font&gt;g;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;and iterate over the results as follows:&lt;br /&gt;&lt;br /&gt;&lt;font face="courier new"&gt;&lt;font color="#0000ff"&gt;foreach &lt;/font&gt;(&lt;font color="#0000ff"&gt;var&amp;nbsp;&lt;/font&gt;g &lt;font color="#0000ff"&gt;in &lt;/font&gt;res)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(g.Key ?? &lt;font color="#800000"&gt;&amp;quot;(null)&amp;quot;&lt;/font&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;foreach &lt;/font&gt;(&lt;font color="#0000ff"&gt;var &lt;/font&gt;s &lt;font color="#0000ff"&gt;in &lt;/font&gt;g)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;- {0}&amp;quot;&lt;/font&gt;, s.CompanyName);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_10.png" width="372" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_11.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointreadyforOrcasBeta2_1DF5/image_thumb_11.png" width="240" border="0" /&gt;&lt;/a&gt; &amp;nbsp;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;There&amp;#39;s more to come, so stay tuned!&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12637" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Releases" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Releases/default.aspx" /></entry><entry><title>The 0.2.2 alpha interim release - an overview</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/20/the-0-2-2-alpha-interim-release-an-overview.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/20/the-0-2-2-alpha-interim-release-an-overview.aspx</id><published>2007-07-20T21:01:17Z</published><updated>2007-07-20T21:01:17Z</updated><content type="html">&lt;p&gt;Today, a new alpha of LINQ to SharePoint will be released to web: &lt;strong&gt;&lt;font color="#ff0000"&gt;please welcome &lt;/font&gt;&lt;/strong&gt;&lt;a href="http://www.codeplex.com/LINQtoSharePoint/Release/ProjectReleases.aspx?ReleaseId=5973" target="_blank"&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;build 0.2.2&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.&amp;nbsp;It&amp;#39;s considered to be an interim release in between the 0.2 and 0.3 milestone.&amp;nbsp;Remember from earlier posts that the goal in the 0.3 milestone is to provide update support through the entity model.&amp;nbsp;The road ahead to reach that goal is still fairly long, but&amp;nbsp;huge steps have been taken&amp;nbsp;since the 0.2 release to&amp;nbsp;support this. Although most of the work in the 0.2.2 interim release is focusing on stability and enablers for future release highlights, there are quite a bit features that will certainly interest you:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Refactoring of the core model&lt;/font&gt;&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;SharePointDataSource&amp;lt;T&amp;gt; is now obsolete, &lt;strong&gt;SharePointDataContext and SharePointDataList&amp;lt;T&amp;gt;&lt;/strong&gt; are the public classes that replace the SharePointDataSource&amp;lt;T&amp;gt;.  &lt;ul&gt; &lt;li&gt;&lt;em&gt;SharePointDataContext&lt;/em&gt; is the heart of the framework, responsible to keep track of lists, entity updates, connecting to the underlying providers, etc.  &lt;li&gt;&lt;em&gt;SharePointDataList&amp;lt;T&amp;gt;&lt;/em&gt; can be compared to a Table&amp;lt;T&amp;gt; in LINQ to SQL, but it refers to a SharePoint list instead, where T stands for the entity class.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;The &lt;strong&gt;entity model&lt;/strong&gt; has been changed, SharePointListEntity no longer exists.  &lt;ul&gt; &lt;li&gt;Entities are regular classes but decorated with a ListAttribute and FieldAttributes on the properties.  &lt;li&gt;The deprecation of the SharePointListEntity base class means we don&amp;#39;t have a Dictionary&amp;lt;string, object&amp;gt; based storage of fields anymore. Field values are just kept in properties and their backing private class members.  &lt;li&gt;To support updates, entities will typically implement &lt;em&gt;INotifyPropertyChang[ing|ed]&lt;/em&gt;.  &lt;li&gt;The entity generator, SPML and SpMetal (see further) take care of generating the &amp;quot;ideal&amp;quot; entity type for a given SharePoint list.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;Provider-based model&lt;/strong&gt; to carry out SharePoint communication such as querying and updating. We&amp;#39;ll provide a web services and object model implementation out of the box. Right, no other SharePoint communication mechanisms&amp;nbsp;exist today (AFAIK), but this model allows us to separate concerns inside the core engine. &lt;li&gt;Close &lt;strong&gt;correspondence to &lt;/strong&gt;the &lt;strong&gt;LINQ to SQL&lt;/strong&gt; model: if you learn LINQ to SQL, it shouldn&amp;#39;t be too difficult to get up to speed with LINQ to SharePoint because of similar principles and constructs (e.g. data contexts, deferred loading, entity refs and sets, ...)&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Improved query parser&lt;/font&gt;&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;The query parser (&lt;em&gt;QueryParser&lt;/em&gt;) was &lt;strong&gt;split&lt;/strong&gt; from the execution part (&lt;em&gt;CamlQuery&lt;/em&gt;).  &lt;li&gt;Lots of bugs were fixed, thanks to a more complete &lt;strong&gt;code coverage&lt;/strong&gt; by unit tests.  &lt;li&gt;Remodeled support for &lt;strong&gt;URL fields&lt;/strong&gt;.  &lt;li&gt;Parser can now &lt;strong&gt;report parse errors&lt;/strong&gt; instead of throwing exceptions, depending on the &lt;strong&gt;run mode&lt;/strong&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;strong&gt;&lt;font color="#800000"&gt;Tool support enhancements&lt;/font&gt;&lt;/strong&gt;  &lt;ul&gt; &lt;li&gt;The enhanced debugger visualizer runs the parser in &lt;strong&gt;error checking mode&lt;/strong&gt; and indicates errors in a written query.  &lt;li&gt;SpMetal is now a pure front-end to an &lt;strong&gt;entity generator&lt;/strong&gt; that also hosted in Visual Studio 2008 as a &amp;quot;single file generator&amp;quot;.  &lt;ul&gt; &lt;li&gt;Entities are mapped using &lt;strong&gt;SPML&lt;/strong&gt;, the &amp;quot;SharePoint &lt;em&gt;Mapping&lt;/em&gt; Language&amp;quot;. Today it&amp;#39;s still minimalistic, but the mapping (XML-based) language will get more complete in subsequent releases.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;There&amp;#39;s an &lt;strong&gt;MSI setup&lt;/strong&gt; for the library together with the tool support. This is required to wire up all the necessary registry settings for VS IDE integration.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Tool support&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;Let&amp;#39;s take a closer look at the tool support side of the 0.2.2 story. First of all, we have a &lt;strong&gt;setup &lt;/strong&gt;available to install the LINQ to SharePoint binaries. &lt;font color="#ff0000"&gt;&lt;strong&gt;&lt;u&gt;Important:&lt;/u&gt;&lt;/strong&gt; you should install the &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=05E0DD12-8394-402B-8936-A07FE8AFAFFD&amp;amp;displaylang=en" target="_blank"&gt;Windows SharePoint Services SDK&lt;/a&gt; prior to installing LINQ to SharePoint. &lt;/font&gt;The setup can take a while since it needs to reconfigure Visual Studio 2008 Orcas Beta 1 for tools integration:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="195" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Once you&amp;#39;ve done the setup, a new &amp;quot;item template&amp;quot; should&amp;nbsp;appear in Visual Studio. Create a new application project and go to Add, New Item:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_1.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_1.png" width="156" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;You&amp;#39;ll see LINQ to SharePoint in this dialog right now:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="145" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_2.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This allows you to create a SPML mapping file with support of a wizard. Give it a useful name, such as Northwind.spml (on my demo machine I&amp;#39;ve copied the Products, Categories and Suppliers tables from &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034&amp;amp;displaylang=en" target="_blank"&gt;SQL Server&amp;#39;s Northwind sample database&lt;/a&gt; to SharePoint lists) and click Add. Now the wizard appears:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_3.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="220" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_3.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Click Next to continue:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="220" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_4.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now specify the URL to the server and the method to log on. Click Test connection to validate the connection info, which will make the Next button available if everything&amp;#39;s okay. So, click Next:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_5.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="215" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_5.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This dialog is where the real work happens: check the lists of your choice at the left-hand side. If you select a list at the left, the right-hand side will show all of the fields. In the current release, the right portion doesn&amp;#39;t affect entity creation yet. In a subsequent release you&amp;#39;ll have more control over the entity creation process than just selecting lists. Click Next:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_6.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="220" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_6.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;And click finish to create the SPML file:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_7.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="166" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_7.png" width="640" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This file is turned into a C# of VB file automatically, as you can see in Solution Explorer. Feel free to browse through the generated code file to see the entity declaration:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_8.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This is it for what the export of entities is concerned. Now it&amp;#39;s time to write some queries. Start by creating an object of type NorthwindSharePointDataContext, which is the &amp;quot;root&amp;quot; of the LINQ to SharePoint library. From this custom data context (that inherits from SharePointDataContext), you can start to write queries as shown below. Notice the IntelliSense that&amp;#39;s available during the whole query writing process (click to enlarge):&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_9.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="104" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_9.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_11.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="143" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_11.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_12.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="171" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_12.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_14.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="112" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_14.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Finally we can execute the code:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_15.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="118" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_15.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Or you could write a more complex query:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_17.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="126" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_17.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_16.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="118" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_16.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;Tip:&lt;/u&gt; Convince yourself this is consistent with the results of the Northwind database&amp;#39;s &amp;quot;Ten Most Expensive Products&amp;quot; sproc. This would be a great LINQ to SQL exercise as well.&lt;/p&gt; &lt;p&gt;On to the debugger visualizer. Set a breakpoint on the first Console.WriteLine statement and run under the debugger:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_18.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="128" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_18.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now click the magnifier glass that appears on the res variable. This will bring up the visualizer:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_19.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="122" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_19.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;In here you can see your query as well as the corresponding CAML. This can be used to spot bugs in the query, i.e. constructs not supported by CAML. This is shown in the screenshot below:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_20.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="113" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_20.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Hover of the red text to get more information about the problem. If you continue the execution of the program, a runtime exception will be raised when the query has to be executed, in our case at iteration time:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_21.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="148" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/The0.2.2alphainterimreleasewhattoexpect_226D/image_thumb_21.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The error message corresponds to the first error you saw in the debugger visualizer (in this case there was only one).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Trivia - what has happened to 0.2.1?&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;blockquote&gt; &lt;p&gt;Due to various modifications to the&amp;nbsp;entity model, tools were getting out of sync with the query parser and execution engine back-end. Because of this we decided not to publish the 0.2.1 release. In 0.2.2 we&amp;#39;re back in sync and the desired quality level of the various components is getting close to the ultimate goal.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;What&amp;#39;s coming after 0.2.2?&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Another interim release, likely 0.2.3 and planned for mid August, will cover:  &lt;ul&gt; &lt;li&gt;List attachments  &lt;li&gt;Additions to SPML and SpMetal improvements (generate SPML, consume SPML) + improvements for the entity wizard &lt;li&gt;Grouping support (under investigation)  &lt;li&gt;Support for User fields (under investigation)&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;The 0.3 alpha release:  &lt;ul&gt; &lt;li&gt;Almost-complete entity model  &lt;li&gt;Update support  &lt;li&gt;Support for Views (under investigation)&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Depending on the Orcas beta, RC, RTM&amp;nbsp;schedule, we might decide to postpone releases&amp;nbsp;in order to get in sync with the&amp;nbsp;latest Orcas build.&amp;nbsp;Other features on the wish list are enhanced tool support, compiled queries, etc but time will tell how things evolve.&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12603" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Releases" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Releases/default.aspx" /><category term="Tools" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Tools/default.aspx" /></entry><entry><title>Lookup fields inside out</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/10/lookup-fields-inside-out.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/10/lookup-fields-inside-out.aspx</id><published>2007-07-10T23:14:28Z</published><updated>2007-07-10T23:14:28Z</updated><content type="html">&lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Introduction&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;Lookup fields are one of the most powerful list-related features of SharePoint, together with their big brothers, the LookupMulti fields. First of all, let&amp;#39;s introduce these field types briefly. In the screenshot below you can see a Northwind Products list in SharePoint with at the right-hand side two Lookup fields: Category en Supplier. These two fields refer to items in another list, in this case Categories and Suppliers:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_1.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="155" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_1.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The definition of such a field is shown below:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="189" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_2.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Using &amp;#39;Allow multiple values&amp;#39;, you can turn the column into a LookupMulti list, referring to multiple items instead of just one.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;How to map? SPML is your friend!&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;So far so good. But how can we use these fields in LINQ to SharePoint? Of course it all starts by creating the entity types. To do this, we can either use the SpMetal command line tool, or (starting with the upcoming 0.2.1 interim release) the SPML mapping language. It&amp;#39;s sufficient to map just the Products list, the entity generator will automatically figure out all of the lists that are referred to in the list&amp;#39;s definition recursively, either using Lookup or LookupMulti fields. The entity generator is smart enough to eliminate cycles in such a list cross-reference graph and export all of the entity types you need. In this case, I&amp;#39;ll just export the Products list with the following SPML definition:&lt;/p&gt; &lt;p&gt;&amp;lt;&lt;font color="#800000"&gt;SharePointDataContext&lt;/font&gt; &lt;font color="#ff0000"&gt;Name&lt;/font&gt;=&amp;quot;&lt;font color="#0000ff"&gt;Demo&lt;/font&gt;&amp;quot; &lt;font color="#ff0000"&gt;Url&lt;/font&gt;=&amp;quot;&lt;u&gt;&lt;font color="#0000ff"&gt;http://wss3demo&lt;/font&gt;&lt;/u&gt;&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;font color="#800000"&gt;Lists&lt;/font&gt;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;font color="#800000"&gt;List&lt;/font&gt; &lt;font color="#ff0000"&gt;Name&lt;/font&gt;=&amp;quot;&lt;font color="#0000ff"&gt;Products&lt;/font&gt;&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;font color="#800000"&gt;Lists&lt;/font&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;font color="#800000"&gt;SharePointDataContext&lt;/font&gt; &amp;gt; &lt;p&gt;As with all SPML files you still need to set the Custom Tool manually:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_3.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_3.png" width="155" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This will change in the future when we have a Project Item for SPML files, as well as a designer down the road. Now, when we run the entity generator as follows:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_4.png" width="155" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;it will generate the entity types for the Products lists as well as the Suppliers and Categories lists that are referred to:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_5.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="150" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_5.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Introducing deferred loading&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;Time to write some simple&amp;nbsp;query now:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;font color="#008080"&gt;DemoSharePointDataContext&lt;/font&gt; ctx = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#008080"&gt;DemoSharePointDataContext&lt;/font&gt;(&lt;font color="#0000ff"&gt;new &lt;/font&gt;Uri(&lt;font color="#800000"&gt;&amp;quot;http://wss3demo&amp;quot;&lt;/font&gt;));&lt;br /&gt;ctx.Log = &lt;font color="#008080"&gt;Console&lt;/font&gt;.Out;&lt;br /&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;res = (&lt;font color="#0000ff"&gt;from &lt;/font&gt;p in ctx.Products &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.ProductName == &lt;font color="#800000"&gt;&amp;quot;Chai&amp;quot;&lt;/font&gt; &lt;font color="#0000ff"&gt;select &lt;/font&gt;p).AsEnumerable().Single();&lt;br /&gt;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;{0} costs {1} per {2}&amp;quot;&lt;/font&gt;, res.ProductName, res.UnitPrice, res.QuantityPerUnit);&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;On the fourth line you can see a very simple query that just selects on the product&amp;#39;s name. The Single query operator isn&amp;#39;t implemented in LINQ to SharePoint currently, so we insert an AsEnumerable() call to perform the subsequent Single call via LINQ to Objects. After all, this is how the execution looks like:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_6.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="136" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_6.png" width="240" border="0" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;However, what about accessing the Category property of the entity object? To illustrate this, add the following line of code:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;Category of {0} is {1}&amp;quot;&lt;/font&gt;, res.ProductName, &lt;em&gt;res.Category&lt;/em&gt;.CategoryName);&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;In here, we refer to res.Category which is obtained using &lt;strong&gt;deferred loading&lt;/strong&gt;, meaning that we only get the Category data back when the user asks for it:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="119" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_8.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;If you want to get the data right away when executing the query, you could use it in the projection portion of the query:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;res = (&lt;font color="#0000ff"&gt;from &lt;/font&gt;p in ctx.Products &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.ProductName == &lt;font color="#800000"&gt;&amp;quot;Chai&amp;quot;&lt;/font&gt; &lt;font color="#0000ff"&gt;select new &lt;/font&gt;{&amp;nbsp;p.ProductName, p.UnitPrice, p.QuantityPerUnit, p.Category&amp;nbsp;}).AsEnumerable().Single();&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="179" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_10.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Observe the place where the query gets executed, it&amp;#39;s now part of the Products list query operation. You might wonder why we can&amp;#39;t do something SQL&amp;#39;ish to join between lists and get data back that way. The answer is pretty simple: in CAML you&amp;#39;re restricted to querying one list at a time, so we can&amp;#39;t do any better.&lt;/p&gt; &lt;p&gt;Notice the way the &amp;quot;subquery&amp;quot; is composed, as a CAML query using the ID field. This is because we&amp;#39;re able to get identity information of child lists used in Lookup fields&amp;nbsp;(i.e. Category and Supplier) when querying the parent list (in this case Products). Internally, LINQ to SharePoint keeps this data in&amp;nbsp;a so-called LazyLoadingThunk object that&amp;#39;s stored in the entity object&amp;#39;s fields dictionary. When the data for such a field is retrieved using an entity property (which calls into the GetValue method of the base SharePointListEntity class, see fragment below), the LazyLoadingThunk grabs the ID and sends a request to the data context object to go and retrieve that object using a &amp;quot;GetEntityById&amp;quot; call:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;[&lt;font color="#0000ff"&gt;global&lt;/font&gt;::BdsSoft.SharePoint.Linq.&lt;font color="#008080"&gt;FieldAttribute&lt;/font&gt;(&lt;font color="#800000"&gt;&amp;quot;Category&amp;quot;&lt;/font&gt;, &lt;font color="#0000ff"&gt;global&lt;/font&gt;::BdsSoft.SharePoint.Linq.&lt;font color="#008080"&gt;FieldType&lt;/font&gt;.Lookup, Id=&lt;font color="#800000"&gt;&amp;quot;...&amp;quot;&lt;/font&gt;, LookupField=&lt;font color="#800000"&gt;&amp;quot;CategoryName&amp;quot;&lt;/font&gt;)]&lt;br /&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#008080"&gt;Categories &lt;/font&gt;Category {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;get&lt;/font&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;return &lt;/font&gt;((&lt;font color="#008080"&gt;Categories&lt;/font&gt;)(&lt;font color="#0000ff"&gt;base&lt;/font&gt;.&lt;u&gt;GetValue&lt;/u&gt;(&lt;font color="#800000"&gt;&amp;quot;Category&amp;quot;&lt;/font&gt;)));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;set &lt;/font&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;base&lt;/font&gt;.SetValue(&lt;font color="#800000"&gt;&amp;quot;Category&amp;quot;&lt;/font&gt;, &lt;font color="#0000ff"&gt;value&lt;/font&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;LookupMulti fields are treated in a similar way with an entity property that&amp;#39;s a collection type instead (in the current release we use IList&amp;lt;T&amp;gt; as the property type for a LookupMulti field in an entity type, where T stands for another SharePointListEntity subclass). E.g. if the Products list would have a LookupMulti Categories property instead, you&amp;#39;d get an entity definition with a property similar to the following:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;[&lt;font color="#0000ff"&gt;global&lt;/font&gt;::BdsSoft.SharePoint.Linq.&lt;font color="#008080"&gt;FieldAttribute&lt;/font&gt;(&lt;font color="#800000"&gt;&amp;quot;Categories&amp;quot;&lt;/font&gt;, &lt;font color="#0000ff"&gt;global&lt;/font&gt;::BdsSoft.SharePoint.Linq.&lt;font color="#008080"&gt;FieldType&lt;/font&gt;.LookupMulti, Id=&lt;font color="#800000"&gt;&amp;quot;...&amp;quot;&lt;/font&gt;, LookupField=&lt;font color="#800000"&gt;&amp;quot;CategoryName&amp;quot;&lt;/font&gt;)]&lt;br /&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt; &lt;font color="#008080"&gt;IList&lt;/font&gt;&amp;lt;&lt;font color="#008080"&gt;Categories&lt;/font&gt;&amp;gt; Categories {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;get&lt;/font&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;return &lt;/font&gt;((&lt;font color="#008080"&gt;IList&lt;/font&gt;&amp;lt;&lt;font color="#008080"&gt;Categories&lt;/font&gt;&amp;gt;)(&lt;font color="#0000ff"&gt;base&lt;/font&gt;.GetValue(&lt;font color="#800000"&gt;&amp;quot;Categories&amp;quot;&lt;/font&gt;)));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;set &lt;/font&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;base&lt;/font&gt;.SetValue(&lt;font color="#800000"&gt;&amp;quot;Categories&amp;quot;&lt;/font&gt;, &lt;font color="#0000ff"&gt;value&lt;/font&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;u&gt;Note:&lt;/u&gt; If you don&amp;#39;t want to write a projection that calls the Category property (or another Lookup or LookupMulti field) manually in order to retrieve the data right away (which also returns non-entity types which won&amp;#39;t support updating), we&amp;#39;ll provide some other feature modeled after LINQ to SQL &amp;quot;&lt;strong&gt;data shapes&lt;/strong&gt;&amp;quot; in a future release. Such a data shape instructs the data provider to retrieve some fields (in our case typically Lookup or LookupMulti fields) right away when writing a query, even when such&amp;nbsp;a query doesn&amp;#39;t include that field directly (e.g. in a projection). I&amp;#39;ll blog about this feature once we get there in the release cycle.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Using subqueries&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;However, there&amp;#39;s more than just deferred loading when talking about Lookup(Multi) fields. What about querying the parent list in a way like this:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Products &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.Category.CategoryName.StartsWith(&lt;font color="#800000"&gt;&amp;quot;Con&amp;quot;&lt;/font&gt;) &lt;font color="#0000ff"&gt;select &lt;/font&gt;p;&lt;br /&gt;&lt;font color="#0000ff"&gt;foreach&lt;/font&gt; (&lt;font color="#0000ff"&gt;var &lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;res)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;{0} in category {1} costs {2} per unit&amp;quot;&lt;/font&gt;, p.ProductName, p.Category.CategoryName, p.UnitPrice);&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Since we can&amp;#39;t query for multiple lists using just one CAML query, e.g. by doing joins, we have to play quite some tricks to get this to work. When we set a breakpoint on the foreach loop, we can take a look at the &lt;em&gt;res&lt;/em&gt; object at runtime:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_12.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="192" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_12.png" width="640" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This is the result as shown in the debugger visualizer:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_13.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="161" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_13.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Observe the portion I&amp;#39;ve indicated in the red rectangle. It isn&amp;#39;t valid CAML, it&amp;#39;s a so-called &lt;strong&gt;patch&lt;/strong&gt;. Such a patch gets generated by the front-end portion of the parser whenever it observes a &amp;quot;traversal&amp;quot; (such as &lt;u&gt;p.Category&lt;/u&gt;.CategoryName.StartsWith(&lt;font color="#800000"&gt;&amp;quot;Con&amp;quot;&lt;/font&gt;))&amp;nbsp;of a Lookup field in the query predicate (where clause). When the query has to be sent to the server in order to retrieve results, the contents of each patch is wrapped in a separate query that&amp;#39;s executed against the entity type specified by the Patch element&amp;#39;s Field attribute. Based on the results of this &lt;strong&gt;subquery&lt;/strong&gt;, the Patch element is replaced by a tree of &amp;lt;Or&amp;gt; tags in order to select only those list items from the parent list that reference a category that&amp;#39;s matching with the patch&amp;#39;s query. This looks pretty much like a foreign key lookup in relational databases.&lt;/p&gt; &lt;p&gt;&lt;u&gt;Note:&lt;/u&gt; In releases prior to the 0.2.1 interim release, the situation was much more complex (cf. FieldAttribute::IsUnique and EnforeLookupFieldUniqueness)&amp;nbsp;because of the lacking documentation of how to do a &amp;quot;lookup field query &lt;u&gt;by value&lt;/u&gt;&amp;quot;. There&amp;#39;s however an undocumented &lt;strong&gt;LookupId&lt;/strong&gt; attribute on the CAML FieldRef element that allows to do exactly this.&lt;/p&gt; &lt;p&gt;For our sample query, this is the resulting execution plan:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;First, the Category patch is executed. This subquery retrieves the ID field values for all of the categories that start with Con.&lt;br /&gt;&lt;br /&gt;&amp;lt;Query&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;Where&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;CategoryName&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;Con&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/Where&amp;gt;&lt;br /&gt;&amp;lt;/Query&amp;gt;&lt;br /&gt;&amp;lt;ViewFields&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;ID&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;/ViewFields&amp;gt;&lt;br /&gt;&lt;/li&gt; &lt;li&gt;Now, the Category patch is cut from the original pre-parsed query and replaced by a tree of &amp;lt;Or&amp;gt;-conditions chaining all matching category IDs together, like this:&lt;/li&gt; &lt;p&gt;&amp;lt;Query&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;Where&amp;gt;&lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Or&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Lookup&amp;quot;&amp;gt;3&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Category&amp;quot; LookupId=&amp;quot;TRUE&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Lookup&amp;quot;&amp;gt;2&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Category&amp;quot; LookupId=&amp;quot;TRUE&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Or&amp;gt;&lt;/font&gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/Where&amp;gt;&lt;br /&gt;&amp;lt;/Query&amp;gt;&lt;/p&gt;&lt;/ol&gt; &lt;p&gt;As an example, let&amp;#39;s make it a little more difficult with two patches involved. Observe the following query:&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt; res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Products&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.Category.CategoryName.StartsWith(&lt;font color="#800000"&gt;&amp;quot;Con&amp;quot;&lt;/font&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; (p.Supplier.Country == &lt;font color="#800000"&gt;&amp;quot;USA&amp;quot;&lt;/font&gt; &amp;amp;&amp;amp; p.Supplier.Region == &lt;font color="#800000"&gt;&amp;quot;LA&amp;quot;&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; || p.Supplier.Country == &lt;font color="#800000"&gt;&amp;quot;Canada&amp;quot;&lt;/font&gt; &amp;amp;&amp;amp; p.Supplier.Region == &lt;font color="#800000"&gt;&amp;quot;Québec&amp;quot;&lt;/font&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#0000ff"&gt;select &lt;/font&gt;p;&lt;/font&gt; &lt;p&gt;Time to see what the parser builds out of this LINQ query, so take a look at the visualizer screenshot below: &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_15.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_15.png" width="175" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Observe we have two patches this time. The parser is smart enough to coalesce adjacent lookup field traversals, in this case the whole query predicate portion for the supplier condition (USA/LA or Canada/Québec) is brought together in just one patch. This means that LINQ to SharePoint will launch two subqueries before taking on the parent query:&lt;/p&gt; &lt;p&gt;&lt;u&gt;Query corresponding with p.Category.CategoryName.StartsWith(&lt;font color="#800000"&gt;&amp;quot;Con&amp;quot;&lt;/font&gt;):&lt;/u&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&amp;lt;Query&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;Where&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;CategoryName&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;Con&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/BeginsWith&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/Where&amp;gt;&lt;br /&gt;&amp;lt;/Query&amp;gt;&lt;br /&gt;&amp;lt;ViewFields&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;ID&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;/ViewFields&amp;gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;u&gt;Query corresponding with (p.Supplier.Country == &lt;font color="#800000"&gt;&amp;quot;USA&amp;quot;&lt;/font&gt; &amp;amp;&amp;amp; p.Supplier.Region == &lt;font color="#800000"&gt;&amp;quot;LA&amp;quot; &lt;/font&gt;|| p.Supplier.Country == &lt;font color="#800000"&gt;&amp;quot;Canada&amp;quot;&lt;/font&gt; &amp;amp;&amp;amp; p.Supplier.Region == &lt;font color="#800000"&gt;&amp;quot;Québec&amp;quot;&lt;/font&gt;):&lt;/u&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&amp;lt;Query&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;Where&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Or&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;USA&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Country&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;LA&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Region&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;Canada&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Country&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value Type=&amp;quot;Text&amp;quot;&amp;gt;Québec&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;Region&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/And&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Or&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/Where&amp;gt;&lt;br /&gt;&amp;lt;/Query&amp;gt;&lt;br /&gt;&amp;lt;ViewFields&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;FieldRef Name=&amp;quot;ID&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;/ViewFields&amp;gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Next, it will patch the parent query with all of the patch information gathered, resulting in the following: &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_16.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="222" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/Lookupfieldsinsideout_13614/image_thumb_16.png" width="240" border="0" /&gt;&lt;/a&gt;  &lt;p&gt;Finally this piece of CAML is ready for execution by the server to get the final results back. &lt;p&gt;As a final feature under the umbrella of Lookup field support, you can also use entity objects in the query predicate directly, like this: &lt;blockquote&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;cat = (&lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;&lt;font color="#000000"&gt;c&lt;/font&gt; &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Categories &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.CategoryName == &lt;font color="#800000"&gt;&amp;quot;Beverages&amp;quot;&lt;/font&gt; &lt;font color="#0000ff"&gt;select &lt;/font&gt;c).First();&lt;font color="#008000"&gt; //we don&amp;#39;t support the Single query operator, so use First to get the &amp;#39;singleton result&amp;#39;&lt;/font&gt;&lt;br /&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Products &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.Category == cat &lt;font color="#0000ff"&gt;select &lt;/font&gt;p;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;This will grab the primary key field value from the cat variable and use it in similar way as the samples above. &lt;p&gt;&amp;nbsp; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Quiz&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;If you think you&amp;#39;ve understood everything in this post, here&amp;#39;s a little &lt;strong&gt;quiz&lt;/strong&gt;. How many distinct queries will be sent to the server in order to execute the following LINQ query? &lt;blockquote&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;ctx.Products &lt;font color="#0000ff"&gt;where &lt;/font&gt;p.UnitPrice &amp;lt;= 20 &amp;amp;&amp;amp; (p.Category.CategoryName == &lt;font color="#800000"&gt;&amp;quot;Beverages&amp;quot;&lt;/font&gt; || p.Category.CategoryName == &lt;font color="#800000"&gt;&amp;quot;Seafood&amp;quot;&lt;/font&gt;) &amp;amp;&amp;amp; p.Supplier.Country == &lt;font color="#800000"&gt;&amp;quot;USA&amp;quot;&lt;/font&gt; &lt;font color="#0000ff"&gt;orderby &lt;/font&gt;p.UnitPrice &lt;font color="#0000ff"&gt;descending select &lt;/font&gt;p;&lt;br /&gt;&lt;font color="#0000ff"&gt;foreach &lt;/font&gt;(&lt;font color="#0000ff"&gt;var &lt;/font&gt;p &lt;font color="#0000ff"&gt;in &lt;/font&gt;res)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;{0} in category {1} costs {2} and is supplied by {3}.&amp;quot;&lt;/font&gt;, p.ProductName, p.Category.CategoryName, p.UnitPrice, p.Supplier.CompanyName);&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;The output is shown below (&lt;u&gt;tip:&lt;/u&gt; why is this relevant?). &lt;blockquote&gt; &lt;p&gt;Boston Crab Meat in category Seafood costs 18,4 and is supplied by New England Seafood Cannery.&lt;br /&gt;Steeleye Stout in category Beverages costs 18 and is supplied by Bigfoot Breweries.&lt;br /&gt;Sasquatch Ale in category Beverages costs 14 and is supplied by Bigfoot Breweries.&lt;br /&gt;Laughing Lumberjack Lager in category Beverages costs 14 and is supplied by Bigfoot Breweries.&lt;br /&gt;Jack&amp;#39;s New England Clam Chowder in category Seafood costs 9,65 and is supplied by New England Seafood Cannery.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp; &lt;h2&gt;&lt;strong&gt;&lt;font color="#000080"&gt;Conclusion&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt; &lt;p&gt;As you can see, this feature in LINQ to SharePoint frees developers from the burden of having to execute more than one CAML query in order to get the desired results back. In the upcoming 0.2.1 interim release, this feature is fully functional, ready for you to play with it. Notice however that we don&amp;#39;t support lookup field traversals deeper than one. For example, if an item from a Product list has a supplier from a Suppliers list with an address stored in an Addresses list, it won&amp;#39;t be possible to write a predicate like p.Supplier.Address.City == &amp;quot;Seattle&amp;quot; (Address is one bridge too far). This might be subject of a future release if time permits.&lt;/p&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12598" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Internals" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Internals/default.aspx" /></entry><entry><title>Improving the parser and more debugger visualizer fun</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/05/linq-to-sharepoint-improving-the-parser-debugger-visualizer-fun.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/05/linq-to-sharepoint-improving-the-parser-debugger-visualizer-fun.aspx</id><published>2007-07-05T08:00:00Z</published><updated>2007-07-05T08:00:00Z</updated><content type="html">&lt;p&gt;Welcome back to what&amp;#39;s going to end up as &lt;em&gt;&amp;quot;LINQ to SharePoint: The Cruel Sequel&amp;quot;&lt;/em&gt; :-). The last couple of days, LINQ to SharePoint has been a full-time job and the result is getting better and better build after build. In this post, I&amp;#39;d like to highlight another feature that was planned from the start but didn&amp;#39;t make its way to the 0.2 release of last month: &lt;strong&gt;parser enhancements&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;So, what&amp;#39;s up? Simply stated, the query parser so far was a runtime parser only. When executing LINQ to SharePoint queries, the LINQ query expression tree gets parsed sooner or later, possibly throwing exceptions in case something can&amp;#39;t be translated into CAML. A typical example is the following:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;var &lt;/font&gt;res = &lt;font color="#0000ff"&gt;from&amp;nbsp;&lt;/font&gt;u &lt;font color="#0000ff"&gt;in &lt;/font&gt;users &lt;font color="#0000ff"&gt;where &lt;/font&gt;u.FirstName.&lt;u&gt;EndsWith&lt;/u&gt;(&lt;font color="#800000"&gt;&amp;quot;t&amp;quot;&lt;/font&gt;) &lt;font color="#0000ff"&gt;select&lt;/font&gt; u;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The reason this can&amp;#39;t be translated is the EndsWith call on the FirstName entity property. Since CAML doesn&amp;#39;t support an equivalent in its query language, we can&amp;#39;t provide a translation. There are much more such things that make the parse operation fail, due to the relatively limited expressiveness of CAML. The problem however, especially with big queries, is for developers to get to know where the problem is located exactly. In the previous alphas an InvalidOperationException is thrown with some message, possibly referring to something in the query that couldn&amp;#39;t be translated (e.g. &lt;em&gt;&amp;quot;Unsupported string filtering query expression detected: EndsWith. Only the methods Contains and StartsWith are supported.&amp;quot;&lt;/em&gt;). Although this sample message is pretty easy to understand, there are more complex ones that deserve a better approach.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&amp;lt;Intermezzo&amp;gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;To put this in a broader context, you should be aware of the fact that &lt;strong&gt;LINQ lacks support for compile-time query validation by custom query providers&lt;/strong&gt;. All the LINQ-capable compilers (C# 3.0, VB 9.0) do, is generating an expression tree representing the query. Therefore, the only way to find out about problems in the query is to execute the code, which triggers the IQueryable-supported (custom query provider&amp;#39;s) query&amp;nbsp;expression tree parser that can signal issues in the query by throwing some exception. All LINQ providers expose such a behavior. As an example, take a look at the following situation in LINQ to SQL:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointImprovingtheparserdebugg_4F5F/image.png"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="334" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointImprovingtheparserdebugg_4F5F/image_thumb.png" width="666" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Luckily the message is pretty clear in order to figure out what&amp;#39;s going wrong. Also observe the time when and the place where the exception occurs: not at definition time of the query (the query - i.e. &lt;em&gt;var res = ...&lt;/em&gt; in our case - remains an &lt;em&gt;expression&lt;/em&gt;) but when the iteration &lt;em&gt;statement&lt;/em&gt; is executed.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Note:&lt;/u&gt; LINQ to SharePoint alpha 0.1 did produce parse errors at query expression definition time instead; this has been fixed in 0.2 so that the query parser isn&amp;#39;t invoked before query execution time (i.e. iteration over the results).&lt;/p&gt;
&lt;p&gt;So what&amp;#39;s wrong with this? Not that much, except for the fact that&amp;nbsp;we would be able to signal such problems &lt;u&gt;at compile time&lt;/u&gt; if we had the appropriate infrastructure in place at the compiler&amp;#39;s side. This would mean that the C# and VB compiler would have to pass the generated expression tree to the custom query provider&amp;#39;s query parser (which could be interfaced for communication with a front-end compiler) as part of the compilation job. Our query parser could then feed a set of&amp;nbsp;warnings and errors&amp;nbsp;back to the compiler, which are then presented to the developer as regular compiler warnings or errors (albeit generated by the custom query provider instead of the compiler itself).&lt;/p&gt;
&lt;p&gt;Since we don&amp;#39;t have such a thing at this very moment, alternatives have to be invented. That&amp;#39;s exactly what we&amp;#39;ve done in LINQ to SharePoint in order to help the developer spot the location of the problem in his/her query.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&amp;lt;/Intermezzo&amp;gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So, what&amp;#39;s our approach? Of course we don&amp;#39;t drop the NotSupportedException approach: if your query can&amp;#39;t be translated, you&amp;#39;re&amp;nbsp;out of luck and we need to signal this in some way or another at runtime. However, when debugging we provide a debugger visualizer for LINQ to SharePoint queries that allows you to inspect the query, including the generated CAML. Essentially, the debugger visualizer triggers the parser albeit in a slightly different &amp;quot;&lt;strong&gt;parser run mode&lt;/strong&gt;&amp;quot;: instead of throwing exceptions for parse-time errors, all errors are collected and fed back to the visualizer with enough information to spot the problem. A picture is worth a thousand words, so take a look at this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointImprovingtheparserdebugg_4F5F/image_2.png"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="547" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointImprovingtheparserdebugg_4F5F/image_thumb_2.png" width="639" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This is the debugger visualizer for LINQ to SharePoint that will become available in a later release (keep an eye on my blog). At the top of the dialog you can see the LINQ query. Admitted, it&amp;#39;s not in its original shape anymore but it&amp;#39;s the best we can do right now (the original LINQ query in either C# 3.0 or VB 9.0 has been eaten by the respective compiler at this stage of execution). The original query looks as follows:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt; res = &lt;font color="#0000ff"&gt;from &lt;/font&gt;t &lt;font color="#0000ff"&gt;in &lt;/font&gt;lst &lt;font color="#0000ff"&gt;where &lt;/font&gt;!(t.FirstName.Contains(&lt;font color="#800000"&gt;&amp;quot;Bart&amp;quot;&lt;/font&gt;) &amp;amp;&amp;amp; t.Age &amp;gt;= 24) || t.LastName.EndsWith(&lt;font color="#800000"&gt;&amp;quot;De Smet&amp;quot;&lt;/font&gt;) &amp;amp;&amp;amp; &lt;font color="#008080"&gt;CamlMethods&lt;/font&gt;.DateRangesOverlap(t.Modified.Value) &lt;font color="#0000ff"&gt;orderby &lt;/font&gt;1 &lt;font color="#0000ff"&gt;select &lt;/font&gt;t;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The LINQ query you can see in the dialog above is basically the query&amp;#39;s expression tree ToString() call result. With a little knowledge about extension methods and expression trees, you can read such an expression string representation in just a few seconds (as a little exercise play the human compiler, translating a LINQ query to an expression tree followed by a mental ToString-call).&lt;/p&gt;
&lt;p&gt;What the LINQ to SharePoint parser does when running in &amp;quot;&lt;strong&gt;debug mode&lt;/strong&gt;&amp;quot; - in addition to its regular parsing job - is the identification of subexpressions that can&amp;#39;t be translated while continuing the parsing (instead of throwing an exception). All places where something went wrong are marked by &amp;lt;ParseError /&amp;gt; placeholders in the CAML query and each of these have a unique identifier that&amp;#39;s linked (bidirectionally) with the subexpression in the LINQ query that caused the problem. This way, developers can identify problems in a more visually attractive way.&lt;/p&gt;
&lt;p&gt;Even more, in the example above we can see four problems with the query at once. If we&amp;#39;d run the application we&amp;#39;d get only one single exception (which would result in at least four &amp;quot;run-crash-fix&amp;quot; iterations). The goal is to take this to the maximum level possible, providing links from the debugger visualizer to specific help information about the parser issues that occurred (observe the unique identification code on the error, in this case SP0011). In case you&amp;#39;re curious why you&amp;#39;re seeing SP0011 in the fragment above: observe that the t.FirstName.Contains(&amp;quot;Bart&amp;quot;) expression is nested inside a Not expression. CAML doesn&amp;#39;t have a Boolean negation operator in its query schema, so we can&amp;#39;t express the !t.FirstName.Contains(&amp;quot;Bart&amp;quot;) expression as a whole.&lt;/p&gt;
&lt;p&gt;Stay tuned for more LINQ to SharePoint fun soon!&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:8dbbca1a-eeeb-4971-a1a6-a3f527fe3cf9" style="PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;PADDING-BOTTOM:0px;MARGIN:0px;PADDING-TOP:0px;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SharePoint" rel="tag"&gt;SharePoint&lt;/a&gt;, &lt;a href="http://technorati.com/tags/CAML" rel="tag"&gt;CAML&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ%20to%20SharePoint" rel="tag"&gt;LINQ to SharePoint&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Orcas" rel="tag"&gt;Orcas&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12585" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Tools" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Tools/default.aspx" /><category term="Internals" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Internals/default.aspx" /></entry><entry><title>Introducing SPML</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/04/linq-to-sharepoint-introducing-spml.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/04/linq-to-sharepoint-introducing-spml.aspx</id><published>2007-07-04T08:00:52Z</published><updated>2007-07-04T08:00:52Z</updated><content type="html">&lt;p&gt;In today&amp;#39;s post I&amp;#39;d like to introduce a new concept that will be introduced in &lt;a href="http://www.codeplex.com/LINQtoSharePoint" target="_blank"&gt;LINQ to SharePoint&lt;/a&gt; v0.3: &lt;strong&gt;SPML&lt;/strong&gt; or the SharePoint&amp;nbsp;&lt;em&gt;Mapping&lt;/em&gt; Language.&amp;nbsp;It didn&amp;#39;t make it for the &lt;a href="http://www.codeplex.com/LINQtoSharePoint/Release/ProjectReleases.aspx?ReleaseId=5390" target="_blank"&gt;0.2 release&lt;/a&gt; due to time restrictions, but tonight the first portion of the POC code has been checked in to CodePlex. So what&amp;#39;s it?&lt;/p&gt; &lt;p&gt;Let&amp;#39;s start with the very beginning: &lt;strong&gt;SpMetal&lt;/strong&gt;. As you might already know, the SpMetal tool is used to generate entity classes from a SharePoint list definition. It connects up to the SharePoint site, grabs the list definition and converts it into some entity class type that can be used to write queries using SharePointDataSource&amp;lt;T&amp;gt;. Therefore, the core of its work is to generate code either in C# 3.0 or VB 9.0. To set our minds, here&amp;#39;s a little sample:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="118" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;em&gt;The syntax of SpMetal&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_1.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_1.png" width="195" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;em&gt;A list with various fields&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_2.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="118" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_2.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;em&gt;SpMetal in action, exporting the Demo list&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_3.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="167" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_3.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;em&gt;Code generated by SpMetal&lt;/em&gt;&lt;/p&gt; &lt;p&gt;In the very first alpha of LINQ to SharePoint (before we went live on CodePlex), there was no such tool at all and the creation of entity classes was a manual job (after all, it wasn&amp;#39;t so difficult at all yet: there was no base class to derive from and using automatic properties in C# 3.0 the mapping was just a matter of minutes). Lazy as developers (including myself) are, the SpMetal tool was created as a very simple tool based on a quick-n-dirty string concatenation and formatting technique (take a look at the sources to see how it&amp;#39;s done in 0.2). However, things were getting more complex and a few weeks ago work was started to port the tool to a &lt;strong&gt;CodeDOM&lt;/strong&gt;-based approach for code generation. I decided not to merge these changes with the 0.2 release since full testing on the tool&amp;#39;s correctness hasn&amp;#39;t been done yet, so it will become part of 0.3 instead.&lt;/p&gt; &lt;p&gt;However, there&amp;#39;s more than just a new back-end to SpMetal. The cool thing about it is its potential for reuse elsewhere, including the VS 2008 IDE. Over time, the goal is to provide entity creation as easy as dragging and dropping lists from an add-in in Server Explorer to a designer surface. We&amp;#39;re not there yet, but an important milestone is under development right now: &lt;strong&gt;SPML&lt;/strong&gt;. Designers are just overlays on top of some source definition, for example a partial class with Windows Forms designer generated code or a resx file or ... In a similar way, SPML is the source-side of a SharePoint list mapping for LINQ to SharePoint. Currently it&amp;#39;s very minimalistic, but over time it will get more and more expressiveness to drive the mapping process (e.g. you&amp;#39;ll be able to decide which fields to include in the entity mapping and you&amp;#39;ll be able to control a few aspects associated with entity updating, another 0.3 feature that&amp;#39;s under development right now). Let&amp;#39;s take a brief look at it:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_4.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="168" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_4.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Observe a few things:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The file extension of an SPML file is &lt;strong&gt;.spml&lt;/strong&gt; (duh!).  &lt;li&gt;SPML files contain the definition of a SharePointDataContext, something that will be introduced in 0.3 (I&amp;#39;ll blog about it once we get closer to 0.3). For now, think of it as a set of list entities (see &amp;lt;Lists&amp;gt; section).  &lt;li&gt;The SPML file has a Custom Tool associated, called &lt;strong&gt;LINQtoSharePointGenerator&lt;/strong&gt;. You can specify a code namespace as well.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;What the LINQtoSharePointGenerator does is pretty straightforward: it parses the SPML file, finds enough information to connect to the WSS site and lets the SpMetal back-end (now called the EntityGenerator) do the rest of the work, returning a code file (support for VB and C#) that&amp;#39;s added to the solution. Furthermore, it adds a reference to BdsSoft.SharePoint.Linq if it&amp;#39;s not already present. All of this magic is done automatically when you build the project (or you can trigger it manually). This means that using LINQ to SharePoint doesn&amp;#39;t require SpMetal anymore: just write an SPML file and add it to the project with the right Custom Tool setting. Here&amp;#39;s an example:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_6.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="240" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_6.png" width="208" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;em&gt;Manual triggering of the LINQtoSharePointGenerator...&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_7.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="168" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_7.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;em&gt;...the result: a .Designer.cs file&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_8.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="168" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_8.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;em&gt;With VB support included!&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_9.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="168" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointIntroducingSPML_1B7B/image_thumb_9.png" width="240" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;em&gt;Start to write LINQ queries right away&lt;/em&gt;&lt;/p&gt; &lt;p&gt;If you want to play with this already, you can grab the sources from CodePlex (&lt;a href="http://www.codeplex.com/LINQtoSharePoint/SourceControl/DownloadSourceCode.aspx?changeSetId=7418" target="_blank"&gt;change set 7418&lt;/a&gt;). However, the VS Orcas integration requires you have the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1C99A9C8-ADFC-4DE6-8B9E-2A5C6B540332&amp;amp;displaylang=en" target="_blank"&gt;VS Orcas SDK&lt;/a&gt; installed as well. Also remember this is very early work in progress but step by step we&amp;#39;re getting there.&lt;/p&gt; &lt;p&gt;Enjoy!&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:a0d194eb-fb9d-4771-a067-48ba15c00aaf" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SharePoint" rel="tag"&gt;SharePoint&lt;/a&gt;, &lt;a href="http://technorati.com/tags/CAML" rel="tag"&gt;CAML&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ%20to%20SharePoint" rel="tag"&gt;LINQ to SharePoint&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Orcas" rel="tag"&gt;Orcas&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12584" width="1" height="1"&gt;</content><author><name>bart</name><uri>http://blogs.bartdesmet.net/members/bart.aspx</uri></author><category term="Tools" scheme="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/tags/Tools/default.aspx" /></entry><entry><title>LINQ to SharePoint alpha v0.2 available</title><link rel="alternate" type="text/html" href="http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/03/linq-to-sharepoint-alpha-v0-2-available.aspx" /><id>http://blogs.bartdesmet.net/blogs/linqtosharepoint/archive/2007/07/03/linq-to-sharepoint-alpha-v0-2-available.aspx</id><published>2007-07-03T08:00:52Z</published><updated>2007-07-03T08:00:52Z</updated><content type="html">&lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointalphav0.2available_31C8/image.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="82" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointalphav0.2available_31C8/image_thumb.png" width="73" align="left" border="0" /&gt;&lt;/a&gt; Two months after the appearance of the 0.1.2 alpha release of &lt;a href="http://www.codeplex.com/LINQtoSharePoint" target="_blank"&gt;LINQ to SharePoint&lt;/a&gt;, I&amp;#39;m proud to announce the &lt;strong&gt;availability of the 0.2 alpha release&lt;/strong&gt;. If you can&amp;#39;t wait any longer, here&amp;#39;s the &lt;a href="http://www.codeplex.com/LINQtoSharePoint/Release/ProjectReleases.aspx?ReleaseId=5390" target="_blank"&gt;direct link to the release page&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Q: So, what&amp;#39;s new in this release?&lt;br /&gt;A: A bunch!&lt;/p&gt; &lt;p&gt;No seriously, v0.2 is a major milestone on behalf of the query parser. Although the to-do list is growing day after day and the spec is being extended accordinly, 0.2 provides a pretty complete querying experience with support for lots of query constructs, getting near to the (albeit limited) expressiveness of CAML.&lt;/p&gt; &lt;p&gt;As an example, the &lt;strong&gt;CamlMethods&lt;/strong&gt; class was introduced to host the DateRangesOverlap function that couldn&amp;#39;t be represented in regular C# 3.0-ish or VB 9.0-ish expressions.&lt;/p&gt; &lt;p&gt;For what the field types are concerned, lots of work has gone in the design and implementation of &lt;strong&gt;Lookup(Multi) field support&lt;/strong&gt;, which is kind of a masked and burried PK-FK relationship. Although we&amp;#39;re not anywhere near to full join capability, one can traverse a Lookup field link, even in the query:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;var src = new SharePointDataSource&amp;lt;Customers&amp;gt;(uri);&lt;br /&gt;var res = from&amp;nbsp;c in customers where &lt;u&gt;c.Profile&lt;/u&gt;.Age &amp;gt;= 24 select c;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;If you know a bit of CAML it might be a good idea to do a little brainstorming on how such a nested query could be realised. There&amp;#39;s quite some magic in it to make it work. If you think you know the answer, turn on the &lt;strong&gt;logging support&lt;/strong&gt; on SharePointDataSource and you&amp;#39;ll see the CAML query popping up:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;var src = new SharePointDataSource&amp;lt;Customers&amp;gt;(uri);&lt;br /&gt;&lt;u&gt;src.Log = Console.Out;&lt;/u&gt;&lt;br /&gt;var res = from&amp;nbsp;c in customers where &lt;u&gt;c.Profile&lt;/u&gt;.Age &amp;gt;= 24 select c;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;But what about &lt;strong&gt;debug-time inspection of queries&lt;/strong&gt;? As a last-minute addition (with lots of work left to be done in a broader set of IDE supporting development cycles) a &lt;strong&gt;debugger visualizer&lt;/strong&gt; was added:&lt;/p&gt; &lt;p&gt;&lt;a href="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointalphav0.2available_31C8/image_1.png"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="153" alt="image" src="http://community.bartdesmet.net/blogs/linqtosharepoint/WindowsLiveWriter/LINQtoSharePointalphav0.2available_31C8/image_thumb_1.png" width="240" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Pretty cool to my humble opinion :-). I have to disappoint you a bit since the Execute button isn&amp;#39;t functional yet, but this is where we&amp;#39;re going...&lt;/p&gt; &lt;p&gt;I&amp;#39;m a little lazy tonight, so for &lt;strong&gt;even more 0.2 features&lt;/strong&gt; take a look at my &lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2007/06/18/linq-to-sharepoint-announcing-the-0-2-alpha-release.aspx" target="_blank"&gt;previous blog post&lt;/a&gt; on the topic. Notice there are a few &lt;strong&gt;known issues &lt;/strong&gt;(a complete list will appear in the work item list for the 0.2 release over the next couple of days) that have to do with some restrictions in CAML, e.g. when working with DateTime fields in query predicates. Don&amp;#39;t worry however: CAML experts are investigating these in the meantime and hopefully fixes will become available in the 0.3 timeframe.&lt;/p&gt; &lt;p&gt;As we&amp;#39;re finalizing the &lt;strong&gt;planning for 0.3&lt;/strong&gt;, &lt;strong&gt;&lt;font color="#ff0000"&gt;all feedback is still welcome&lt;/font&gt;&lt;/strong&gt;. A few highlights for 0.3 include:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;First pieces of entity update support;  &lt;li&gt;Additional field types support and richer entity model;  &lt;li&gt;Better IDE support for various tasks;  &lt;li&gt;More test coverage and bug fixes;  &lt;li&gt;Refactoring and code maintenance;  &lt;li&gt;...&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The goal is to release 0.3 in August as a stepping stone to get in a beta phase this fall. Depending on the VS 2008 &amp;#39;Orcas&amp;#39; release schedule, adjustments to the schedule might occur to have a better technology alignment.&lt;/p&gt; &lt;p&gt;Stay tuned for more news; I intend to create&amp;nbsp;a few &lt;strong&gt;How-To videos&lt;/strong&gt; the next couple of weeks, covering various topics, usage scenarios and bit of &amp;quot;insights and internals&amp;quot;. Furthermore, an &lt;strong&gt;update to the query parser and infrastructure spec&lt;/strong&gt; will be uploaded to Source Control too.&lt;/p&gt; &lt;p&gt;Have fun!&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:34c713dc-f1f5-4715-960f-0a0561d5a01a" style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px;"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/LINQ" rel="tag"&gt;LINQ&lt;/a&gt;, &lt;a href="http://technorati.com/tags/SharePoint" rel="tag"&gt;SharePoint&lt;/a&gt;, &lt;a href="http://technorati.com/tags/CAML" rel="tag"&gt;CAML&lt;/a&gt;, &lt;a href="http://technorati.com/tags/LINQ%20to%20SharePoint" rel="tag"&gt;LINQ to SharePoint&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Orcas" rel="tag"&gt;Orcas&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.bartdesmet.net/aggbug.aspx?PostID=12582" width="1" height="1"&gt;</content><author><name>bart</na