<?xml version="1.0" encoding="utf-8"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Nancy Brown</title><link>http://sharepoint.mindsharpblogs.com/NancyB</link><description /><copyright>(C) 2013 Mindsharp</copyright><lastBuildDate>Wed, 19 Jun 2013 10:24:59 GMT</lastBuildDate><generator>RSSBuilder: 1.0.0.0</generator><item><author>Nancy Brown</author><title>SharePoint's REST: an OData Overview</title><guid>/NancyB/archive/2012/07/27/SharePoint[squo]s-REST[coln]-an-OData-Overview.aspx</guid><link>/NancyB/archive/2012/07/27/SharePoint[squo]s-REST[coln]-an-OData-Overview.aspx</link><pubDate>Fri, 27 Jul 2012 09:19:00 GMT</pubDate><description>&lt;div class=ExternalClass135FFDCE7FDB4B5F9D2678A1F89EEA2F&gt;&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div class=ExternalClassFA68891A6EFA4B3F9269AB508B0D2888&gt;
&lt;div&gt;What is REST exactly? &lt;a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm"&gt;&lt;strong&gt;Re&lt;/strong&gt;presentational &lt;strong&gt;S&lt;/strong&gt;tate &lt;strong&gt;T&lt;/strong&gt;ransfer&lt;/a&gt;, aka &lt;a href="http://en.wikipedia.org/wiki/Representational_State_Transfer"&gt;REST&lt;/a&gt;, is an architectural style for web-based data access, an alternative to other techniques like SOAP Web Services and Remote Procedure Calls. Or as Todd Bleeker so aptly put it, it's &amp;quot;Query by URL.&amp;quot; It's simpler than SOAP or RPC, and is catching on everywhere. &lt;a href="http://www.odata.org/"&gt;OData&lt;/a&gt; is a protocol - a standardized way to implement REST to surface, query, and manipulate data. REST isn't necessarily focused on data, but OData is, so think &amp;quot;Oh DATA!&amp;quot;. This post is a thumbnail sketch of REST/OData in general, and SharePoint REST/OData 2010 and 2013. Note that all SharePoint 2013 comments are based on the SharePoint Server 2013 Technical Preview, a preliminary version subject to change.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;font size=2&gt;OData: Query by URL, Answer by RSS&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt; &lt;/div&gt;
&lt;div&gt;OData is an &lt;a href="http://www.microsoft.com/openspecifications/en/us/programs/osp/default.aspx"&gt;open&lt;/a&gt; web-data protocol developed by Microsoft. OData is all about web-based data access; it's a natural evolution of Web Services and Object-Relational Mappings. It's like having LINQ to SQL classes (or some other Object-Relational Mapping) available by URL.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;OData can make almost any kind of structured data collection available to any kind of platform, because all data access is via plain old HTTP, and the data is served up as XML (or JSON) in an Atom-style RSS feed. Imagine - a database (or other structured data) can be available for virtually any ad hoc query from almost any internet-connected device. And not just queries- all CRUD operations are available.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;SharePoint REST/OData is client-side data access. For code targeting SharePoint 2010 or SharePoint 2013 data, if any of the Client-Side Object Models (CSOM) are available, those are likely the best choices. But if the code is in a non-Windows context, maybe a LAMP application or an Android/iOS phone App, then SharePoint REST/OData is likely the way to go. On the other hand, REST/OData could be a means of bringing external data into SharePoint; Netflix, ebay, twitpics, StackOverflow, and NuGet all have OData feeds. A general understanding of REST could also be useful for consuming Twitter, LinkedIn, or Facebook's REST APIs.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;Exploring OData&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;OData.org lists a number of &lt;a href="http://www.odata.org/ecosystem#liveservices"&gt;OData services&lt;/a&gt; available for playing around with REST queries right in the browser. If LINQ is comfortable, then another way to wrap your head around REST-speak (or at least get help translating) is &lt;a href="http://www.linqpad.net/"&gt;LINQPad&lt;/a&gt;. It's a free tool for exploring LINQ, OData, and code in general. Point LINQPad at an OData service (select &amp;quot;WCF Data Services&amp;quot; as the Data Context to build automatically, enter URL, set Database), write and run a LINQ query, then click the SQL button to see the REST URL that was generated. (Or the RequestLog button if it's LINQPad targeting .NET Framework 4.) Here's LINQPad 4 querying an Announcements List in a SharePoint 2010-style ListData.svc service - the URL is in the bottom right pane:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="LINQPad showing REST URL" src="/NancyB/Lists/Photos/OData_LINQPad.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;(Sadly, pointing LINQPad at the new SharePoint 2013 OData service _vti_bin/Client.svc results in an error.) Another gotta-have free tool for OData is &lt;a href="http://www.fiddler2.com/fiddler2/"&gt;Fiddler2&lt;/a&gt;. This Web Debugging Proxy lets you inspect each HTTP request and response.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;Entity Data Model&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;OData is built on the Entity Data Model - yes, think .NET Entity Framework and WCF Data Services, which can be used to create OData services in a flash. It's like any Object-Relational Mapping (ORM); one just needs to learn the lingo. In a RDBMS like SQL Server, tables contain rows; in OData, Collections contain Entries. In a database, tables can be related; in OData, Collections can be associated. A row has columns. An Entry has properties. Tables may have keys; Collections always have keys. Browsing to the service root of an OData service usually displays an Atom+XML list of all available Collections. Here's the Microsoft Northwind database as OData:&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;img alt="Browser showing OData service root" src="/NancyB/Lists/Photos/OData_Browser_ServiceRoot.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;To see the metadata for this service, append $metadata to the service URL and OData responds with EntityTypes and Properties and NavigationProperties.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing service metadata" src="/NancyB/Lists/Photos/OData_Browser_Metadata.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Wait a minute- Collections have &lt;em&gt;Entries&lt;/em&gt;, so why does the metadata contain &lt;em&gt;EntityTypes&lt;/em&gt;? As is often the case, there are multiple sets of terminology at work. Entity Data Model (EDM) and OData have parallel terms:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="OData and EDM parallel terms" src="/NancyB/Lists/Photos/OData_EDM_Terms.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Query an Entity Set (Collection) by appending its name to the service URL - here's the Customers Collection URL: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing OData Collection" src="/NancyB/Lists/Photos/OData_Browser_Collection.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;This returns a feed full of Entries - just like rows in a data table. There's a bunch of metadata for each Entry, like id, title, author, date-time updated, and there are links to related items, which contain relative URLs like &amp;quot;Customers('ALFKI')/Orders&amp;quot;. Note in the screenshot above, in the metadata for the first entry, the id is a URL: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI'"&gt;http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI'&lt;/a&gt;) - that's how to retrieve just that one Entry. The actual data for this Entry is contained inside the entry/content/properties element at the bottom of the screenshot: CustomerID, CompanyName, ContactName,…&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;URL Structure&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;An OData Url has three parts: a Service root, a resource path, and (optionally) query string options. We've seen the service root, which typically returns a list of all available Collections. The resource path is kind of like a relative URL, and identifies a Collection or a single Entry or a property of an Entry. Basically the resource path drills down through the entity model to get to a particular object. OData URLs are usually case-sensitive, so take care with spelling. For example, &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI'"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI'&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;)&lt;/strong&gt; returns just the ALFKI Customer, which is a single Entry identified by its key:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing single Entry" src="/NancyB/Lists/Photos/OData_Browser_SingleEntry.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;To get just one Property of an Entry, tack on the Property name (note the forward slash delimiter): &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Address"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI')/Address&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing single Property" src="/NancyB/Lists/Photos/OData_Browser_SingleProperty.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;To return just the value of the Property, with no XML wrapper, add /$value to the URL: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Address/$value"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI')/Address/$value&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing value of single Property" src="/NancyB/Lists/Photos/OData_Browser_PropertyValue.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Related Entries can be retrieved by following the associations in the URL: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Orders(10643)/Order_Details"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI')/Orders(10643)/Order_Details&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing related Entries" src="/NancyB/Lists/Photos/OData_Browser_RelatedEntries.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Or to return just the collection of related Links, without the actual entries, use the $links option between the Entry and its related Collection, like this: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/$links/Orders"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI')/$links/Orders&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing related Links" src="/NancyB/Lists/Photos/OData_Browser_RelatedLinks.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Query string options, like $value and $links used above, begin with &amp;quot;$&amp;quot; and are part of the query language.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;Query Language&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The query language provides 
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;options&lt;/strong&gt; ($filter, $sort, $orderby, $top, $expand, $skip, $take, $metadata, …)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;operators&lt;/strong&gt; (eq, ne, gt, ge, lt, le, and, or, not, mod, add, sub, …)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;functions&lt;/strong&gt; (startswith, substring, replace, tolower, trim, round, ceiling, day, month, year, typeof, …)&lt;/li&gt;&lt;/ul&gt;Since these will be part of a URL query string, symbols like &amp;quot;+&amp;quot;, &amp;quot;-&amp;quot;, and &amp;quot;=&amp;quot; already have assigned meanings, hence the need to represent them by text like &amp;quot;add&amp;quot;, &amp;quot;sub&amp;quot;, and &amp;quot;eq&amp;quot;. Most of these options, operators, and functions have familiar names, and do just what their names suggest.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;To query Northwind for the top three UK Customers, as sorted by Postal Code, add options as needed: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=Country eq 'UK'&amp;amp;$orderby=PostalCode&amp;amp;$top=3"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers?$filter=Country eq 'UK'&amp;amp;$orderby=PostalCode&amp;amp;$top=3&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing Query Language" src="/NancyB/Lists/Photos/OData_Browser_QueryLanguage.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;$expand is used to return related Entries inline (inside the Entry), like this: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')?$expand=Orders"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI')?$expand=Orders&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing $expand Option" src="/NancyB/Lists/Photos/OData_Browser_ExpandOption.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;In the screenshot above, note there is an entire feed inside the inline element - all the related orders are returned. Instead of XML, this could be returned as JavaScript Object Notation (JSON) by appending $format=JSON to the query string: &lt;a href="http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')?$expand=Orders&amp;amp;$format=JSON"&gt;http://services.odata.org/Northwind/Northwind.svc/&lt;strong&gt;Customers('ALFKI')?$expand=Orders&amp;amp;$format=JSON&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;When the browser receives the JSON, it will probably offer to save it rather than show it. Opening that saved JSON file in Visual Studio looks like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Wisual Studio showing returned JSON" src="/NancyB/Lists/Photos/OData_VisualStudio_JSON.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Note: appending $format=JSON does not work with SharePoint REST/OData, but there are other ways to get SharePoint REST/OData to return JSON.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;CRUD via HTTP Verbs&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;OData uses the Atom Publishing Protocol, (AtomPub), as the means of Creating, Reading, Updating, and Deleting (CRUD-ing) content. Typically the payload of the HTTP Request is Atom+XML or JSON formatted Entries, like the Entries returned from a query. The HTTP verb is what determines the CRUD action. 
&lt;ul&gt;
&lt;li&gt;Create = HTTP POST&lt;/li&gt;
&lt;li&gt;Read = HTTP GET&lt;/li&gt;
&lt;li&gt;Update = HTTP PUT or HTTP MERGE&lt;/li&gt;
&lt;li&gt;Delete = HTTP DELETE&lt;/li&gt;&lt;/ul&gt;Update is an HTTP PUT or MERGE; a PUT replaces an existing entry, by updating all values with the new ones in the request, and setting to default all others. MERGE replaces old values, but leaves anything not specified untouched. Concurrency is maintained by ETags, but we're getting beyond the scope of this post.&lt;br&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;SharePoint and REST/OData&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;In SharePoint 2010, only Lists were available as OData services. The service URL was based on the site and looked like this: &lt;a href="http://server/site/_vti_bin/ListData.svc"&gt;http://server/site/_vti_bin/&lt;strong&gt;ListData.svc&lt;/strong&gt;&lt;/a&gt;. Probably the most common way for a SharePoint developer to interact with SharePoint 2010 REST/OData was via a service proxy (a DataContext). Working with a service proxy is easy-peasy; just add a Service Reference to a Visual Studio project, and a tool will generate the proxy for you. Instantiate the proxy class, passing the constructor the URL of the site, set credentials, and issue LINQ queries. Under the covers, that LINQ query will be translated into a REST URL and sent to the server, where it gets translated into a LINQ to SharePoint query, which in turn gets translated into CAML. The proxy will translate the returned XML back into .NET objects.&lt;br&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Diagram of SharePoint 2010 OData flow" src="/NancyB/Lists/Photos/OData_SharePoint2010Flow.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's a short C# code example that uses a proxy to retrieve a SharePoint 2010 List as a Generic .NET List:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;OperationsProxy.ProjectRoleItem&amp;gt; RoleList&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;get&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;            &lt;/span&gt;OperationsProxy.OperationsDataContext ctx =&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; OperationsProxy.OperationsDataContext(&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;http://intranet/operations/_vti_bin/ListData.svc&amp;quot;&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;            &lt;/span&gt;ctx.Credentials = CredentialCache.DefaultCredentials;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; ctx.ProjectRole.ToList();&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;In SharePoint 2013, REST/OData access is no longer limited to Lists - it covers virtually everything the CSOM does, including Site Collections and Webs. This expanded REST/OData service is &lt;strong&gt;Client.svc&lt;/strong&gt;, which can be accessed in two ways:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;http://server/site/_vti_bin/Client.svc&lt;/li&gt;
&lt;li&gt;http://server/site/_api&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;The &amp;quot;_api&amp;quot; friendly name is preferred, since it's easier to read. The old SharePoint 2010 /_vti_bin/ListData.svc is still there in SharePoint 2013, and is handy if only List data is needed.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;In a Visual Studio project, adding a Service Reference for an _api service will fail. The way to talk to _api is typically JavaScript, probably using jQuery, which makes AJAX requests and parsing JSON much simpler. However, this means manually constructing the correct URL, rather than using LINQ and a proxy class to do a translation. Since SharePoint Site Collections and Webs are complex objects, not simple tables, OData functions (methods) are much more prevalent.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;There are 5 access points for the _api service:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Site Collections - http://server/site/_api/site&lt;/li&gt;
&lt;li&gt;Webs - http://server/site/_api/web&lt;/li&gt;
&lt;li&gt;User Profiles - http://server/site/_api/userProfiles&lt;/li&gt;
&lt;li&gt;Search - http://server/site/_api/search&lt;/li&gt;
&lt;li&gt;Publishing - http://server/site/_api/publishing&lt;/li&gt;&lt;/ul&gt;
&lt;div&gt;Happily, many OData URLs can be constructed by starting with the corresponding CSOM method, then replacing &amp;quot;.&amp;quot; with &amp;quot;/&amp;quot;. For example:&lt;/div&gt;
&lt;div&gt;&lt;br&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="URL construction for SharePoint 2013 OData Query" src="/NancyB/Lists/Photos/OData_SharePoint2013_URLconstruction.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Digging just a little deeper, retrieve just the Title and Author fields from List Item with ID=2 of the Announcements List, as HTML:&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;a href="http://spb2/sites/team/_api/web/lists/getbytitle('Announcements')/items(2)/FieldValuesAsHtml/?$select=Title,Author"&gt;http://spb2/sites/team/_api/web/lists/getbytitle('Announcements')/items(2)/FieldValuesAsHtml/?$select=Title,Author&lt;/a&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Browser showing SharePoint 2013 OData Query" src="/NancyB/Lists/Photos/OData_Browser_SharePoint2013.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Note that the Author field is formatted with presence information, including a link, which navigates to the My Site for that user:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="SharePoint 2013 My Site" src="/NancyB/Lists/Photos/OData_SharePoint2013_MySite.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;This is just the proverbial tip of the iceberg - see &lt;a href="http://msdn.microsoft.com/en-us/library/fp142380(v=office.15).aspx"&gt;Get started with the SharePoint 2013 REST service&lt;/a&gt; in MSDN to really whet your whistle.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2012/07/27/SharePoint[squo]s-REST[coln]-an-OData-Overview.aspx#Comments</comments><category>SharePoint 2013 Development</category></item><item><author>Nancy Brown</author><title>Integrating jqGrid with SharePoint QuickStart</title><guid>/NancyB/archive/2012/05/15/Integrating-jqGrid-with-SharePoint-QuickStart.aspx</guid><link>/NancyB/archive/2012/05/15/Integrating-jqGrid-with-SharePoint-QuickStart.aspx</link><pubDate>Tue, 15 May 2012 06:42:00 GMT</pubDate><description>&lt;div class=ExternalClassD969A6C100FE407495EBDB3CF6A0E5D8&gt;
&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div class=ExternalClassDFFCAE6018D843B9854836FC927C6CF1&gt;
&lt;div&gt;Want an ajax-type grid to display tabular data in SharePoint? Try jqGrid. It's built on jQuery, easily configured, substantial documentation, sponsored by Microsoft, and there's even a &amp;quot;Redmond&amp;quot; jQuery theme which looks like it was made for SharePoint's out of the box style.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="jqGrid in action" src="/NancyB/Lists/Photos/jqGridDemo.Gif"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;jqGrid can do a lot more than just display tabular data; it offers CRUD operations, subgrids, grouping, searching, and more. Check out the &lt;a href="http://www.trirand.com/blog/jqgrid/jqgrid.html"&gt;demos page&lt;/a&gt; for some ideas. This post is just about getting off the ground with jqGrid in SharePoint. For easy data, we'll use the venerable Northwinds sample database from an OData source. Basic steps are:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Download jqGrid &lt;a href="http://www.trirand.com/blog/?page_id=6"&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Download a jQuery theme &lt;a href="http://jqueryui.com/themeroller/"&gt;there&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Register jqGrid CSS and JavaScript with SharePoint&lt;/li&gt;
&lt;li&gt;Configure jqGrid&lt;/li&gt;
&lt;li&gt;Create a Data Adapter for jqGrid&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Register jqGrid CSS and JavaScript with SharePoint&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We'll build this jqGrid in a SharePoint Visual Web Part. Start with a SharePoint 2010 project containing a Visual Web Part, and add a &amp;quot;Layouts&amp;quot; Mapped Folder. It's a good idea to keep all the project stuff corralled, so the first subfolder under Layouts might well be named for the project. Then add &lt;strong&gt;css&lt;/strong&gt; and &lt;strong&gt;js&lt;/strong&gt; subfolders for the downloaded jQuery components.&lt;/p&gt;
&lt;p&gt;Open the downloaded jQuery theme's css folder and copy the subfolder with your theme name to the SharePoint project's css folder. In this example, that's the &amp;quot;redmond&amp;quot; folder, including all its contents. Also from the downloaded jQuery theme, open the js subfolder, and copy the custom js file to the SharePoint project's js folder. In this example, that's the jquery-ui-1.8.20.custom.min.js file. OK, theme's done.&lt;/p&gt;
&lt;p&gt;&lt;img alt="jqGrid CSS and JavaScript in SharePoint" src="/NancyB/Lists/Photos/jqGridFolders.png"&gt;&lt;/p&gt;
&lt;p&gt;Now we just need four files from the jqGrid download:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Copy to the SharePoint &lt;strong&gt;css&lt;/strong&gt; folder: &lt;strong&gt;ui.jqgrid.css&lt;/strong&gt; from the jqGrid download's css folder&lt;/li&gt;
&lt;li&gt;Copy to the SharePoint &lt;strong&gt;js&lt;/strong&gt; folder:&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;jquery.jgGrid.min.js&lt;/strong&gt; and &lt;strong&gt;jquery-1.7.2.min.js&lt;/strong&gt; from the jqGrid download's js folder&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;grid.locale-en.js &lt;/strong&gt;(or the language pack of your choice), from the download's js/i18n folder&lt;/li&gt;&lt;/ol&gt;&lt;/ul&gt;
&lt;p&gt;Keeping things SharePoint-y, we'll register these with SharePoint constructs. To the Visual Web Part's Elements.xml file, add CustomAction elements similar to these just above the closing &lt;span style="line-height:115%;font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Elements&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt; tag:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt;Register JQuery scripts&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;CustomAction&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Sequence&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;100&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;ScriptSrc&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;/_layouts/Mindsharp.OData.JQuery/js/jquery-1.7.2.min.js&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Location&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ScriptLink&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;CustomAction&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Sequence&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;110&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;ScriptSrc&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;/_layouts/Mindsharp.OData.JQuery/js/jquery-ui-1.8.20.custom.min.js&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Location&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ScriptLink&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;CustomAction&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Sequence&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;120&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;ScriptSrc&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;/_layouts/Mindsharp.OData.JQuery/js/grid.locale-en.js&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Location&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ScriptLink&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;CustomAction&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Sequence&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;130&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;ScriptSrc&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;/_layouts/Mindsharp.OData.JQuery/js/jquery.jqgrid.min.js&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Location&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ScriptLink&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Most CustomAction elements add a link somewhere, but when the Location attribute is ScriptLink, it registers a script. The Sequence attribute is critical to getting these on the page in the right order. Be sure to edit the ScriptSrc value to match the path in your project.&lt;/p&gt;
&lt;p&gt;To the Visual Web Part's ascx HTML source, add CssRegistration tags similar to this just below the default directives:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;SharePoint&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;:&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;CssRegistration&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;span style="color:red"&gt;runat&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="color:red"&gt;Name&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;/_layouts/Mindsharp.OData.JQuery/css/redmond/jquery-ui-1.8.20.custom.css&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="color:red"&gt;ID&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;CssRegistration1&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;SharePoint&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;:&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;CssRegistration&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;SharePoint&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;:&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;CssRegistration&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;span style="color:red"&gt;runat&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;server&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="color:red"&gt;Name&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;/_layouts/Mindsharp.OData.JQuery/css/ui.jqgrid.css&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="color:red"&gt;ID&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;CssRegistration2&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;SharePoint&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;:&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;CssRegistration&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Once again, the path in the Name attribute must match your project.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Configure jqGrid&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This will be a very basic and minimal configuration. Check out the &lt;a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs"&gt;documentation&lt;/a&gt; for all the options. To the Visual Web Part's ascx source, just below the CssRegistration tags, add this html and script:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;div&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;jqGrid&amp;quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon"&gt;table&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;Northwinds&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon"&gt;table&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon"&gt;div&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;NorthwindsPager&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon"&gt;div&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;div&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;script&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;span style="color:red"&gt;type&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;text/JavaScript&amp;quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;$(document).ready(&lt;span style="color:blue"&gt;function&lt;/span&gt; () {&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;$(&lt;span style="color:maroon"&gt;&amp;quot;#Northwinds&amp;quot;&lt;/span&gt;).jqGrid({&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;url: L_Menu_BaseUrl + &lt;span style="color:maroon"&gt;'/_layouts/Mindsharp.OData.JQuery/NorthwindsXML.aspx'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;datatype: &lt;span style="color:maroon"&gt;'xml'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;mtype: &lt;span style="color:maroon"&gt;'GET'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;autowidth: &lt;span style="color:blue"&gt;true&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;height: 230,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;  &lt;/span&gt;colNames: [&lt;span style="color:maroon"&gt;'Customer ID'&lt;/span&gt;, &lt;span style="color:maroon"&gt;'Company'&lt;/span&gt;, &lt;span style="color:maroon"&gt;'Address'&lt;/span&gt;, &lt;span style="color:maroon"&gt;'City'&lt;/span&gt;, &lt;span style="color:maroon"&gt;'Country'&lt;/span&gt;],&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;colModel: [&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{ name: &lt;span style="color:maroon"&gt;'id'&lt;/span&gt;, width: 125 },&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{ name: &lt;span style="color:maroon"&gt;'company'&lt;/span&gt;, width: 250 },&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{ name: &lt;span style="color:maroon"&gt;'address'&lt;/span&gt;, width: 125, sortable: &lt;span style="color:blue"&gt;false&lt;/span&gt; },&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{ name: &lt;span style="color:maroon"&gt;'city'&lt;/span&gt;, width: 100, sortable: &lt;span style="color:blue"&gt;false&lt;/span&gt; },&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{ name: &lt;span style="color:maroon"&gt;'country'&lt;/span&gt;, width: 100, sortable: &lt;span style="color:blue"&gt;false&lt;/span&gt; }&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;],&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;pager: &lt;span style="color:maroon"&gt;'#NorthwindsPager'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;rowNum: 10,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;rowList: [10, 20],&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;sortname: &lt;span style="color:maroon"&gt;'id'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;sortorder: &lt;span style="color:maroon"&gt;'asc'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;viewrecords: &lt;span style="color:blue"&gt;true&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;gridview: &lt;span style="color:blue"&gt;true&lt;/span&gt;,&lt;span&gt;  &lt;/span&gt;&lt;span style="color:darkgreen"&gt;// insert all the data at once (speedy)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;caption: &lt;span style="color:maroon"&gt;'Northwinds Customers via OData'&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;});&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:darkgreen"&gt;// Add Navigator functions&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;$(&lt;span style="color:maroon"&gt;&amp;quot;#Northwinds&amp;quot;&lt;/span&gt;).jqGrid(&lt;span style="color:maroon"&gt;'navGrid'&lt;/span&gt;, &lt;span style="color:maroon"&gt;'#NorthwindsPager'&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{ edit: &lt;span style="color:blue"&gt;false&lt;/span&gt;, add: &lt;span style="color:blue"&gt;false&lt;/span&gt;, del: &lt;span style="color:blue"&gt;false&lt;/span&gt;, search: &lt;span style="color:blue"&gt;false&lt;/span&gt; });&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;});&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:maroon;font-size:9.5pt"&gt;script&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The table with id=&amp;quot;Northwinds&amp;quot; will be replaced by the grid (as specified by the &lt;span style="line-height:115%;font-family:Consolas;font-size:9.5pt"&gt;$(&lt;span style="color:maroon"&gt;&amp;quot;#Northwinds&amp;quot;&lt;/span&gt;).jqGrid&lt;/span&gt; script bit at the top of the script), and the div with id=&amp;quot;NorthwindsPager&amp;quot; will be replaced by the navigation and paging bar below the grid (that's the &lt;span style="line-height:115%;font-family:Consolas;font-size:9.5pt"&gt;pager: &lt;span style="color:maroon"&gt;'#NorthwindsPager'&lt;/span&gt;&lt;/span&gt; bit near the middle of the script).&lt;/p&gt;
&lt;p&gt;Like many jQuery-based controls, a url attribute specifies the datasource, which is the NorthwindsXML.aspx which we'll build soon. SharePoint relative urls can confuse jQuery controls, so help them out by using the SharePoint-generated javascript variable L_Menu_BaseUrl like this:&lt;/p&gt;
&lt;p&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:9.5pt"&gt;url: &lt;b&gt;L_Menu_BaseUrl&lt;/b&gt; + &lt;span style="color:maroon"&gt;'/_layouts/Mindsharp.OData.JQuery/NorthwindsXML.aspx'&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Most of the configuration is self-explanatory. &lt;strong&gt;datatype&lt;/strong&gt; and &lt;strong&gt;mtype &lt;/strong&gt;tell jqGrid to use a GET request and expect an XML response. (JSON is another data type option.) &lt;strong&gt;colNames &lt;/strong&gt;is an array of column headers for the grid. &lt;strong&gt;colModel &lt;/strong&gt;defines those columns. Here, &lt;strong&gt;name &lt;/strong&gt;is a unique name for the column, and will be used in the querystring, &lt;strong&gt;width &lt;/strong&gt;sets a starting width (these will be adjusted to fit the parent element's width, due to the &lt;strong&gt;autowidth &lt;/strong&gt;attribute also specified), and &lt;strong&gt;sortable &lt;/strong&gt;determines whether that column can be sorted. Since jqGrid sends an Ajax query every time a sortable column header is clicked, or the page number is changed, or the pager dropdown is changed, or a pager button is clicked, only enable sorting on columns you'd like to code for. &lt;strong&gt;sortable &lt;/strong&gt;is true by default, so turn it off where not wanted.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;rowNum &lt;/strong&gt;sets the initial number of rows to show in the grid, so it should be one of the values in &lt;strong&gt;rowList&lt;/strong&gt;, which is the set of values for the number-of-rows-to-fetch dropdown in the pager bar. &lt;strong&gt;viewRecords: true &lt;/strong&gt;instructs jqGrid to write the &amp;quot;View X to Y of Z&amp;quot; text on the right side of the pager bar.&lt;/p&gt;
&lt;p&gt;&lt;img alt="jqGrid Navigation and Pager Bar" src="/NancyB/Lists/Photos/jqGridPagerBar.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sortname &lt;/strong&gt;is the initial sort field and &lt;strong&gt;sortorder &lt;/strong&gt;the initial sort direction (&amp;quot;asc&amp;quot; or &amp;quot;desc&amp;quot;). The Navigator bar is left of the pager, in the same bar. Since this is a read-only data source, all editing functions and search will be turned off by the &lt;strong&gt;navGrid &lt;/strong&gt;part of the script, and only the refresh button will appear in the Navigator bar.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Create a Data Adapter for jqGrid&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The grid needs a few global values returned in addition to the actual data. Specifically, it wants the number of the page returned, the total number of pages available, and the total number of records available. In XML data, jqGrid expects a &amp;quot;rows&amp;quot; root element, then page, total, and records elements, and a row element for each row of data returned. The row element should contain an id attribute (the primary index value), and cell elements for each column. CDATA sections are fine for data that needs it. Looks like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Example of jqGrid XML data source" src="/NancyB/Lists/Photos/jqGridXML.png"&gt;&lt;/p&gt;
&lt;p&gt;Since most web services don't emit this structure, we'll need to build a data adapter. Often this would be a generic HTTP handler (a .ashx file extension), but a simple aspx page will work just fine, and be a little less trouble to install in SharePoint. Add a text file to the project-named subfolder under the Layouts folder, but give it an .aspx extension; in this example, that's NorthwindsXML.aspx. Add another text file with the same name + .cs (like NorthwindsXML.aspx.cs), and Visual Studio will combine it with the .aspx added earlier. Paste something like this into the .aspx file (adapted to your project name and aspx name, of course):&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;background:yellow;font-size:9.5pt"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;@&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;span style="color:maroon"&gt;Assembly&lt;/span&gt; &lt;span style="color:red"&gt;Name&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;$SharePoint.Project.AssemblyFullName$&amp;quot;&lt;/span&gt; &lt;span style="background:yellow"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;background:yellow;font-size:9.5pt"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;@&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; &lt;span style="color:maroon"&gt;Page&lt;/span&gt; &lt;span style="color:red"&gt;Language&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;CodeBehind&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;NorthwindsXML.aspx.cs&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;Mindsharp.OData.JQuery.NorthwindsXML&amp;quot;&lt;/span&gt; &lt;span style="background:yellow"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Since we're only sending back XML, we don't need a lot of directives. To the code behind file, (NorthwindsXML.aspx.cs in this example), add something like:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System.Collections.Generic;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System.Linq;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System.Text;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System.Web;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System.Xml.Linq;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;using&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; System.Collections.Specialized;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;namespace&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt; Mindsharp.OData.JQuery&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;partial&lt;/span&gt; &lt;span style="color:blue"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;NorthwindsXML&lt;/span&gt; :&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;System.Web.UI.&lt;span style="color:#2b91af"&gt;Page&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;protected&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color:blue"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;Response.ContentType = &lt;span style="color:#a31515"&gt;&amp;quot;text/xml&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;Response.Write(CreateXML());&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The Northwinds database is published as an OData feed courtesy of OData.org. If you've ever used ListData.svc in SharePoint, (example: &lt;a href="http://intranet/_vti_bin/ListData.svc"&gt;http://intranet/_vti_bin/ListData.svc&lt;/a&gt;), you've used an OData feed. If OData is new to you, look into &lt;a href="http://odata.org/"&gt;http://odata.org&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ee535480.aspx"&gt;Query SharePoint Foundation with ADO.NET Data Services&lt;/a&gt;. Basically it is entity classes served up in an Atom Pub style RSS feed, queryable by URL - it's REST for SharePoint List data. But back to the Northwinds OData - add a service reference to &lt;a href="http://services.odata.org/Northwind/Northwind.svc"&gt;http://services.odata.org/Northwind/Northwind.svc&lt;/a&gt;, and give the proxy class a namespace- in this example it's NorthwindProxy.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Add Service Reference for OData feed" src="/NancyB/Lists/Photos/jqGridAddServiceReference.png"&gt;&lt;/p&gt;
&lt;p&gt;Now we can create some XML from our OData feed. This particular feed is read-only, and has a server-side page limit of 20 items. For simplicity, we'll stay within that limit with our jqGrid configuration. Here's the CreateXML method:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;private&lt;/span&gt; &lt;span style="color:blue"&gt;string&lt;/span&gt; CreateXML()&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;NorthwindProxy.&lt;span style="color:#2b91af"&gt;NorthwindEntities&lt;/span&gt; ctx =&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; NorthwindProxy.&lt;span style="color:#2b91af"&gt;NorthwindEntities&lt;/span&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;http://services.odata.org/Northwind/Northwind.svc&amp;quot;&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;int&lt;/span&gt; totalRecords = (&lt;span style="color:blue"&gt;from&lt;/span&gt; c &lt;span style="color:blue"&gt;in&lt;/span&gt; ctx.Customers&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;                  &lt;/span&gt;&lt;span style="color:blue"&gt;select&lt;/span&gt; c).Count();&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:green"&gt;// Initialize variables to contain validated query string parameters &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;string&lt;/span&gt; sortField = &lt;span style="color:blue"&gt;default&lt;/span&gt;(&lt;span style="color:blue"&gt;string&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;string&lt;/span&gt; sortDirection = &lt;span style="color:blue"&gt;default&lt;/span&gt;(&lt;span style="color:blue"&gt;string&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;int&lt;/span&gt; maxRowsToReturn = &lt;span style="color:blue"&gt;default&lt;/span&gt;(&lt;span style="color:blue"&gt;int&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;int&lt;/span&gt; pageToReturn = &lt;span style="color:blue"&gt;default&lt;/span&gt;(&lt;span style="color:blue"&gt;int&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:green"&gt;// Computed variable to send back to jqGrid&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;int&lt;/span&gt; totalPages = &lt;span style="color:blue"&gt;default&lt;/span&gt;(&lt;span style="color:blue"&gt;int&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;CreateValuesFromQuerystring(Request.QueryString, totalRecords,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;out&lt;/span&gt; sortField, &lt;span style="color:blue"&gt;out&lt;/span&gt; sortDirection,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;out&lt;/span&gt; maxRowsToReturn, &lt;span style="color:blue"&gt;out&lt;/span&gt; pageToReturn, &lt;span style="color:blue"&gt;out&lt;/span&gt; totalPages);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; query = CreateQuery(ctx, sortField, sortDirection,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;maxRowsToReturn, pageToReturn, totalRecords);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; customerQuery = &lt;span style="color:blue"&gt;from&lt;/span&gt; c &lt;span style="color:blue"&gt;in&lt;/span&gt; query&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                         &lt;/span&gt;&lt;span style="color:blue"&gt;select&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                         &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                           &lt;/span&gt;c.CustomerID,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                           &lt;/span&gt;c.CompanyName,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                           &lt;/span&gt;c.Address,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                           &lt;/span&gt;c.City,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                           &lt;/span&gt;c.Country&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                         &lt;/span&gt;};&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt; xrows = &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;rows&amp;quot;&lt;/span&gt;,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;page&amp;quot;&lt;/span&gt;, pageToReturn),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;total&amp;quot;&lt;/span&gt;, totalPages),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;records&amp;quot;&lt;/span&gt;, totalRecords));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;foreach&lt;/span&gt; (&lt;span style="color:blue"&gt;var&lt;/span&gt; c &lt;span style="color:blue"&gt;in&lt;/span&gt; customerQuery)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;xrows.Add(&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;row&amp;quot;&lt;/span&gt;, &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XAttribute&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;, c.CustomerID),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;cell&amp;quot;&lt;/span&gt;, c.CustomerID),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;cell&amp;quot;&lt;/span&gt;, c.CompanyName),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;cell&amp;quot;&lt;/span&gt;, c.Address),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;cell&amp;quot;&lt;/span&gt;, c.City),&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;XElement&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;cell&amp;quot;&lt;/span&gt;, c.Country))&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:green"&gt;// XDocument does not provide the XML declaration, so here it is&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;string&lt;/span&gt; xmlDeclaration = &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;?xml version =\&amp;quot;1.0\&amp;quot; encoding=\&amp;quot;utf-8\&amp;quot;?&amp;gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;+ &lt;span style="color:#2b91af"&gt;Environment&lt;/span&gt;.NewLine;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; xmlDeclaration + xrows.ToString();&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;The CreateValuesFromQuerystring() method reads the querystring and guarantees that all the variables harvested from it will have a valid value. A typical query for this project may look like this:&lt;/p&gt;
&lt;blockquote style="margin-right:0px" dir=ltr&gt;
&lt;p&gt;GET /_layouts/Mindsharp.OData.JQuery/NorthwindsXML.aspx?_search=false&amp;amp;nd=1337027722102&amp;amp;rows=10&amp;amp;page=2&amp;amp;sidx=id&amp;amp;sord=asc&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;
&lt;p&gt;Note that jqGrid throws in a Unix-style timestamp (nd=1337027722102), which helps defeat inadvertent browser caching.&lt;/p&gt;
&lt;p&gt;Linq allows chaining of queries- meaning a single query can be built up in multiple statements, and a query can be the subject of another query. Take a look at these methods which build the Linq query dynamically by chaining:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IQueryable&lt;/span&gt;&amp;lt;NorthwindProxy.&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;&amp;gt; CreateQuery(&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;NorthwindProxy.&lt;span style="color:#2b91af"&gt;NorthwindEntities&lt;/span&gt; ctx,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;string&lt;/span&gt; sortField, &lt;span style="color:blue"&gt;string&lt;/span&gt; sortDirection, &lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;int&lt;/span&gt; maxRowsToReturn, &lt;span style="color:blue"&gt;int&lt;/span&gt; pageToReturn, &lt;span style="color:blue"&gt;int&lt;/span&gt; totalRecordsAvailable)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; query = &lt;span style="color:blue"&gt;from&lt;/span&gt; customer &lt;span style="color:blue"&gt;in&lt;/span&gt; ctx.Customers&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                  &lt;/span&gt;&lt;span style="color:blue"&gt;select&lt;/span&gt; customer;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;query = AddOrderBy(query, sortField, sortDirection);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;query = query.Skip(maxRowsToReturn * (pageToReturn - 1))&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                  &lt;/span&gt;.Take(maxRowsToReturn);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; query;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IQueryable&lt;/span&gt;&amp;lt;NorthwindProxy.&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;&amp;gt; AddOrderBy(&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:#2b91af"&gt;IQueryable&lt;/span&gt;&amp;lt;NorthwindProxy.&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;&amp;gt; query, &lt;span style="color:blue"&gt;string&lt;/span&gt; field, &lt;span style="color:blue"&gt;string&lt;/span&gt; direction)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (direction == &lt;span style="color:#a31515"&gt;&amp;quot;asc&amp;quot;&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;switch&lt;/span&gt; (field)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;default&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;query = query.OrderBy(c =&amp;gt; c.CustomerID);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;company&amp;quot;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;query = query.OrderBy(c =&amp;gt; c.CompanyName);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;switch&lt;/span&gt; (field)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;default&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;query = query.OrderByDescending(c =&amp;gt; c.CustomerID);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;company&amp;quot;&lt;/span&gt;:&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;query = query.OrderByDescending(c =&amp;gt; c.CompanyName);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;   &lt;/span&gt;&lt;span&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; query;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;There are cooler ways to dynamically add the OrderBy clause, but we're keeping things simple. For the curious, see Scott Guthrie's post on &lt;a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx"&gt;Dynamic Linq queries&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;That should take care of the data adapter for the grid, so it's ready to deploy. Add the Web Part to a page and enjoy!&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2012/05/15/Integrating-jqGrid-with-SharePoint-QuickStart.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>LINQ query on a DataTable to filter, group, sort, and select distinct</title><guid>/NancyB/archive/2012/04/27/LINQ-query-on-a-DataTable-to-filter,-group,-sort,-and-select-distinct.aspx</guid><link>/NancyB/archive/2012/04/27/LINQ-query-on-a-DataTable-to-filter,-group,-sort,-and-select-distinct.aspx</link><pubDate>Fri, 27 Apr 2012 06:36:00 GMT</pubDate><description>&lt;div class=ExternalClassA536622AC3944B7DA981B1166EC1DA64&gt;
&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div class=ExternalClassBFB753A9519F42CFB2F00EF301A0718B&gt;
&lt;div&gt;I love LINQ, and I wish I had more time to become really proficient in it. &amp;lt;sigh/&amp;gt; But there's so much to do and so little time, it's on a need to know basis. When I &lt;em&gt;need&lt;/em&gt; to know it, I experiment and learn more, firing up LINQPad and pulling out my trusty copy of &lt;em&gt;LINQ Pocket Reference &lt;/em&gt;by Joseph &amp;amp; Ben Albabari. A recent LINQ adventure was this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;blockquote style="margin-right:0px" dir=ltr&gt;
&lt;div&gt;from a DataTable containing names and times, &lt;br&gt;pull out the most recent DataRow for each name, provided it is inside a certain time window, and &lt;br&gt;present just those DataRows sorted by name &lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;That's not hard for a human to think about, but translating it to LINQ took a while. In the process I rediscovered the lovely &lt;strong&gt;let&lt;/strong&gt; function in LINQ, which aided readability, and made the returned set a simple IEnumerable&amp;lt;DataRow&amp;gt;.  That's really helpful, because the typical result of a grouping operation is an IEnumerable of IEnumerables.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's the test DataTable as loaded up in LINQPad:&lt;/div&gt;
&lt;div&gt;&lt;br&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;DataTable dt = &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; DataTable(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;SharePointUsers&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;DataColumn LoginColumn = &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; DataColumn(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;string&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.Columns.Add(LoginColumn);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;DataColumn PageUrlColumn = &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; DataColumn(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;PageUrl&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;string&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.Columns.Add(PageUrlColumn);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;DataColumn AccessTimeColumn = &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; DataColumn(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;AccessTime&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;typeof&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;(DateTime));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.Columns.Add(AccessTimeColumn);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.BeginLoadData();&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\User3&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now.AddMinutes(-&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;5&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\User3&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now.AddSeconds(-&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;119&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\Admin&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now.AddMinutes(-&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;2&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;span&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\Admin&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\User2&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now.AddMinutes(-&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;1&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\User1&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now.AddSeconds(-&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;121&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;dt.LoadDataRow(&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;new&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;object&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;[] { &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Office14\\User1&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, &lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;http://intranet/Default.aspx&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;, DateTime.Now.AddMinutes(-&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;3&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) }, &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;true&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;);&lt;span&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="line-height:115%;font-family:Consolas;color:black;font-size:10pt"&gt;dt.EndLoadData();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The time window will be 2 minutes (120 seconds). So if the AccessTime column value is within 2 minutes of right now, that row should be included for further evaluation. Those rows that pass the time test need to be grouped by names - which is the Login column. The LINQ group keyword essentially creates a list of lists. So the LINQ expression&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;blockquote style="margin-right:0px" dir=ltr&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;from&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;in&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; dt.AsEnumerable()&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;group&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;by&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row.Field&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;string&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;into&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; userGroup&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;creates little lists for each name found, like this: &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="LINQ to DataTable grouping by a row column" src="/NancyB/Lists/Photos/LINQtoDataTable_group.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Ok, so far so good, but that query basically results in a list of lists. Each one of those little name-lists needs to be sorted by DateTime, and just the most recent one pulled out. This is where the let keyword shines. The &lt;a href="http://msdn.microsoft.com/en-us/library/bb310804.aspx"&gt;let&lt;/a&gt; keyword in LINQ creates a new variable right there in the middle of the LINQ query, or as Microsoft puts it, the let keyword &amp;quot;introduces a range variable to store sub-expression results in a query expression&amp;quot;. And that new variable can be queryable! If the group keyword is followed by a let clause, then those name-lists can be sorted on DateTime, just the top one taken (the most recent one), and all that stored in a new variable, like this, where userGroup refers to those name-lists:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;blockquote style="margin-right:0px" dir=ltr&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;group&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;by&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row.Field&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;string&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;into&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; userGroup&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;let&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; lastAccessRows =&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;       &lt;/span&gt;userGroup.OrderByDescending(r =&amp;gt; r.Field&amp;lt;DateTime&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;AccessTime&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;))&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt" class=MsoNormal&gt;&lt;span style="line-height:115%;font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;       &lt;/span&gt;.Take(&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;color:#c81efa;font-size:10pt"&gt;1&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;color:black;font-size:10pt"&gt;)&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt;Now we're cooking. Adding some initial filtering and final sorting and selecting, the complete query and supporting variables look like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;blockquote style="margin-right:0px" dir=ltr&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;Double timeWindow = &lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;120&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;DateTime startTime = DateTime.Now.AddSeconds(-timeWindow);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;var&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; query = &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;from&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;in&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; dt.AsEnumerable()&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;                    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;where&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:10pt"&gt;// AccessTime is later than startTime&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                           &lt;/span&gt;DateTime.Compare(row.Field&amp;lt;DateTime&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;AccessTime&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;), startTime) &amp;gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;0&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                     &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;group&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;by&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; row.Field&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;string&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;) &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;into&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; userGroup&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                     &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;let&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; lastAccessRows =&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                           &lt;/span&gt;userGroup.OrderByDescending(r =&amp;gt; r.Field&amp;lt;DateTime&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;AccessTime&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;))&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                           &lt;/span&gt;.Take(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#c81efa;font-size:10pt"&gt;1&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                     &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;from&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; dr &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;in&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; lastAccessRows&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                     &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;orderby&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt; dr.Field&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:10pt"&gt;string&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;&amp;gt;(&lt;/span&gt;&lt;span style="font-family:Consolas;color:#dc1414;font-size:10pt"&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style="font-family:Consolas;color:black;font-size:10pt"&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt" class=MsoNormal&gt;&lt;span style="line-height:115%;font-family:Consolas;color:black;font-size:10pt"&gt;&lt;span&gt;                     &lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;color:blue;font-size:10pt"&gt;select&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;color:black;font-size:10pt"&gt; dr;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here it is in LINQPad:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="LINQ to DataTable to filter, group, sort, and select distinct" src="/NancyB/Lists/Photos/LINQtoDataTable.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;If I were ever stranded on a desert island, with an inexplicable wireless network and a laptop, and I could only have three free tools, I'd grab LINQPad, Reflector (free version), and Fiddler - couldn’t live without them.&lt;/div&gt;
&lt;div&gt;&lt;br&gt;Hope this helps!&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2012/04/27/LINQ-query-on-a-DataTable-to-filter,-group,-sort,-and-select-distinct.aspx#Comments</comments><category>.NET Development</category></item><item><author>Nancy Brown</author><title>Restoring an SSRS 2012 Shared Data Source in SharePoint: the Missing Link</title><guid>/NancyB/archive/2012/04/11/Restoring-an-SSRS-2012-Shared-Data-Source-in-SharePoint[coln]-the-Missing-Link.aspx</guid><link>/NancyB/archive/2012/04/11/Restoring-an-SSRS-2012-Shared-Data-Source-in-SharePoint[coln]-the-Missing-Link.aspx</link><pubDate>Wed, 11 Apr 2012 06:55:00 GMT</pubDate><description>&lt;div class=ExternalClass4BEEA448F72E401BAA734B9AB994749D&gt;
&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div class=ExternalClassC08FC96D66ED4C01AD0B8F19A99EC289&gt;
&lt;div&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: SQL Server 2012 Reporting Services (SSRS) is installed in SharePoint integrated mode. A Visual Studio 2010 Report Server Project deploys Reports and a Shared Data Source to SharePoint 2010 Document Libraries &amp;quot;Dashboard&amp;quot; and &amp;quot;Data Connections&amp;quot;. Everything works as expected. Then the SharePoint Library &amp;quot;Data Connections&amp;quot;, (which contains the deployed Shared Data Source &amp;quot;TimeBillingDataSource&amp;quot;), is deleted. A new SharePoint Library is created to replace it, on the same Web, with the same name, same Content Type, same everything. The untouched Visual Studio project is redeployed, creating again the same Shared Data Source in a SharePoint Library with the same name, on the same Web. But the Reports in the &amp;quot;Dashboard&amp;quot; Library employing that Shared Data Source are broken.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's the new Library and new Shared Data Source:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Data Connections Library with Newly Created Shared Data Source" src="/NancyB/Lists/Photos/SSRS_DataConnections.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Clicking either report name in the Dashboard Library provokes this error message:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="margin:0in 0in 10pt" class=MsoNormal&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:10pt"&gt;The report server cannot process the report or shared dataset. The shared data source 'TimeBillingDataSource' for the report server or SharePoint site is not valid. Browse to the server or site and select a shared data source.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt;That's because the link is missing.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;But it can be repaired. Click the down-arrow next to a Report name to reveal the context menu, and choose &amp;quot;Manage Data Sources&amp;quot;.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Context Menu Showing 'Manage Data Sources' Option" src="/NancyB/Lists/Photos/SSRS_ManageDataSources.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;On the Manage Data Sources page, click the name of the Data Source…&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Manage Data Sources Page" src="/NancyB/Lists/Photos/SSRS_ManageDataSourcesPage.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;…which leads to a page to manage the actual Shared Data Source, where the Link is missing. Click the ellipsis button (the button with three dots on it)…&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="The Missing Link" src="/NancyB/Lists/Photos/SSRS_MissingLink.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;...and use the &lt;strong&gt;Select an Item &lt;/strong&gt;dialog to find that newly created Shared Data Source in the Data Connections library.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Select the Missing Data Source" src="/NancyB/Lists/Photos/SSRS_SelectItem.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Click OK enough times to get that cemented into place, and then go test that Report.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Report Working Again" src="/NancyB/Lists/Photos/SSRS_Report.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Much better! This process must be repeated for each report that uses the restored Shared Data Source. Another way to fix this for the reports in the Visual Studio project: define a new Shared Data Source with a different name, but the same characteristics. Then for each report that used the deleted Data Source, open the report, and replace the report's Data Source with the new one, then deploy everything.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Why did the link break when the names are the same? Typically SharePoint identifies everything with a GUID, and this is no exception. The ID changed when the Shared Data Source was deployed the second time, and that's when the links went missing.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's the ID before the Data Connections library was deleted, as seen by poking around in the Reporting Service database in SQL Server Management Studio:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="SSMW Before Data Source Library Deletion" src="/NancyB/Lists/Photos/SSRS_SSMSBefore.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Then the SharePoint Library containing the Shared Data Source was deleted and recreated, and the Visual Studio project was re-deployed…&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;------ Deploy started: Project: Mindsharp.Reports.Dashboard, Configuration: Debug ------&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;Deploying to http://intranet/&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;Deploying data source 'http://intranet/Management/Data Connections/TimeBillingDataSource.rsds'.&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;Deploying report 'http://intranet/Management/Dashboard/Hours Summary.rdl'.&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;Deploying report 'http://intranet/Management/Dashboard/Hours Detail.rdl'.&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;Deploy complete -- 0 errors, 1 warnings&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:10pt"&gt;========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;…which leads to a new ID and missing links in the Report Server database:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Missing Links After Library Deleted" src="/NancyB/Lists/Photos/SSRS_SSMSAfter.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Note that the first deployment task is to deploy to the Report Server itself, then to SharePoint.&lt;/div&gt;
&lt;div&gt;Hope that helps!&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2012/04/11/Restoring-an-SSRS-2012-Shared-Data-Source-in-SharePoint[coln]-the-Missing-Link.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>Module Element (Module) 101</title><guid>/NancyB/archive/2012/02/29/Module-Element-(Module)-101.aspx</guid><link>/NancyB/archive/2012/02/29/Module-Element-(Module)-101.aspx</link><pubDate>Wed, 29 Feb 2012 14:09:00 GMT</pubDate><description>&lt;div class=ExternalClassEFF66DC2EB524658948F865AF5B45E94&gt;
&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div&gt;What is a Module? According to the Bing dictionary, the first definition is:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;self-contained interchangeable unit: an independent unit that can be combined with others and easily rearranged, replaced, or interchanged to form different structures or systems&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;In SharePoint, &lt;strong&gt;&amp;lt;Module&amp;gt;&lt;/strong&gt; is the part of CAML (&lt;strong&gt;C&lt;/strong&gt;ollaborative &lt;strong&gt;A&lt;/strong&gt;pplication &lt;strong&gt;M&lt;/strong&gt;arkup &lt;strong&gt;L&lt;/strong&gt;anguage) that provisions files into the Content Database. It has one permissible child element: &lt;strong&gt;&amp;lt;File&amp;gt;&lt;/strong&gt;. So maybe it could have been more mnemonically named &amp;lt;FileProvisioner&amp;gt; or &amp;lt;AddTheseFilesToTheContentDatabase&amp;gt;. However, it does rearrange an independent unit (a file) to form different structures.&lt;/p&gt;
&lt;p&gt;&amp;lt;Module&amp;gt; comes in two flavors: &lt;a href="http://msdn.microsoft.com/en-us/library/ms434127.aspx"&gt;Module Element (Module)&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ms460356.aspx"&gt;Module Element (Site)&lt;/a&gt;. They have the same set of attributes, and the same single child element: &lt;strong&gt;&amp;lt;File&amp;gt;&lt;/strong&gt;. The difference is where each is found, and the starting location for the Module's &lt;strong&gt;Path&lt;/strong&gt; attribute. Module Element (Module) is found in a Feature's Elements.xml, and accordingly the Path attribute is relative to {SharePointRoot}\TEMPLATE\FEATURES\&lt;em&gt;FeatureName&lt;/em&gt;. Module Element (Site) is found in a Site Definition's Onet.xml, and the Path attribute is relative to {SharePointRoot}\TEMPLATE\SiteTemplates\&lt;em&gt;Site_Definition.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Module Element (Module) vs Module Element (Site)" src="/NancyB/Lists/Photos/ModuleComparision.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Modules can rename, repurpose, and provision one physical file to many locations&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This post will focus on Module Element (Module) - the one found in Feature xml - but the concepts are the same for both flavors. For simplicity, Farm Solution Features will be the target of the initial discussion - it is easier to see where the physical files are when they're on the file system. The essence of a Module Element (Module) is taking a file found in its Feature's folder structure, and provisioning that file into the Content Database, so that it becomes a file in an SPWeb's folder or in an SPWeb's list/library. &lt;/p&gt;
&lt;p&gt;Why is a file &amp;quot;provisioned&amp;quot; rather than &amp;quot;copied&amp;quot;? When the Module provisioning process deposits a file into the database, it deposits an SPFile object. When that SPFile is first created (provisioned), it is designated &amp;quot;uncustomized&amp;quot;, meaning it works like a pointer to the actual physical file on the Web Front End (WFE) server's file system - the file in the Feature's folder. In Module provisioning, a single physical file can be virtually renamed, provisioned to multiple locations, and properties can be set, or objects added, depending on what kind of file it is. If the file is an aspx page, navigational elements or web parts can be added. If it is a webpart file, properties can be set. Consider this somewhat contrived illustration:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Module deploys to 5 different locations" src="/NancyB/Lists/Photos/ModuleIllustration.png"&gt;&lt;/p&gt;
&lt;p&gt;In the illustration above, a Module takes a single web part page (BasicLeftRightZones.aspx) and renames, repurposes, and provisions it to five different locations in a web. This is really awesome for scaling purposes. There's just one physical copy of BasicLeftRightZones.aspx, and if that physical copy is changed, the changes are propagated everywhere. However, often a single file just gets provisioned to a single location, but since this is part of Feature deployment, provisioning might happen many times, on multiple Sites or Webs. What if one of those Sites/Webs needs to alter such a file?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Customized or Uncustomized, that is the question&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Imagine that a Feature named &amp;quot;AlphaApp&amp;quot; contains a Module which provisions a file named &amp;quot;Alpha.aspx&amp;quot;, and the AlphaApp Feature has been activated on 3,274 sites. In the database, that's 3,274 &amp;quot;uncustomized&amp;quot; SPFile objects which are pointers to the one physical &amp;quot;Alpha.aspx&amp;quot; in the {SharePointRoot}\TEMPLATE\Features\AlphaApp folder. Then on one of those 3,274 sites, the &amp;quot;Management&amp;quot; site, someone uses SharePoint Designer to alter the source of Management's Alpha.aspx. The Management site's Alpha.aspx SPFile is now &amp;quot;customized&amp;quot;, and no longer functions like a pointer to the file system; instead, the customized Alpha.aspx source is now actually in the database. The SPFile class has a property, CustomizedPageStatus, which indicates whether the file's status is currently &amp;quot;uncustomized&amp;quot; (and cached), &amp;quot;customized&amp;quot; (and not cached), or &amp;quot;none&amp;quot; (never cached). &amp;quot;Cached&amp;quot; means cached in memory on the WFE server. What's with that caching? It goes hand-in-hand with the customized page status. The SPFile class also has method RevertContentStream() which returns the file to its uncustomized state.&lt;/p&gt;
&lt;p&gt;Files can be uncustomized in SharePoint Designer, in code, and through the browser by choosing Site Actions &amp;gt; Site Settings &amp;gt; Reset to Site Definition. This last option lands on the &amp;quot;Reset Page to Site Definition Version&amp;quot; page, where one can select one file to revert, or the entire site. Charmingly, the actual webpage name there is &amp;quot;reghost.aspx&amp;quot;, which is a reference to the old SharePoint way of labeling SPFile files as ghosted or unghosted. In SharePoint 2010 terms, ghosted = uncustomized, unghosted = customized.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Customized/Unghosted or Uncustomized/Ghosted" src="/NancyB/Lists/Photos/ModuleReghost.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;FROM and TO&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If a Module Element (Module) provisions files &lt;strong&gt;from&lt;/strong&gt; a Feature folder &lt;strong&gt;to&lt;/strong&gt; the database, it must have something like a FROM and a TO. Or maybe the &amp;lt;File&amp;gt; element has the FROM and TO. Confusingly, both &amp;lt;Module&amp;gt; and &amp;lt;File&amp;gt; elements have FROM and TO bits.&lt;/p&gt;
&lt;p&gt;Modules elements have a bunch of attributes, but the ones primarily involved in the FROM/TO business are these: Url, Path, and SetupPath. Similarly, the File element has attributes Url, Path, and Name. Some of these do double duty, sometimes acting as a FROM, sometimes acting as a TO. What attributes are required? For a Module, the &lt;strong&gt;Name&lt;/strong&gt; attribute is required; for a File, the &lt;strong&gt;Url &lt;/strong&gt;attribute is required. Let's explore some examples, all based on a web whose Url is &lt;a href="http://intranet/"&gt;http://intranet&lt;/a&gt;. The simplest Module could look like this:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;xml&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;version&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;encoding&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Elements&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;xmlns&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Simple&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Sample.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Elements&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;In the above example, the File element's Url attribute is both the FROM and the TO. This CAML code says that Sample.aspx is in the Feature's root folder, and will be provisioned to the Web's root folder. After provisioning, one could browse to &lt;a href="http://intranet/Sample.aspx"&gt;http://intranet/Sample.aspx&lt;/a&gt;. However, this is an uncommon configuration; in fact, one cannot build this in Visual Studio, since it will not allow files to be added to the Feature's root folder. (There are examples of the Url attribute being both FROM and TO and files living in the Feature's root folder in the built-in Features, such as the BasicWebParts Feature.)&lt;/p&gt;
&lt;p&gt;Since the Url attribute is required for the File element, it will always function as either the FROM or the TO (or both, as above). In the File element, if the Name attribute is added, Name becomes the TO, thus making Url the FROM. If instead the Path attribute is included, Path becomes the FROM, thus making Url the TO. (See why this is confusing?) For the rest of the code examples, just the Module and File elements will be shown. Here's an example using just Url and Name:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Url&lt;span&gt;   &lt;/span&gt;TO: Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Simple&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Sample.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Name&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Alice.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Now one could browse to &lt;a href="http://intranet/Alice.aspx"&gt;http://intranet/Alice.aspx&lt;/a&gt;. The Sample.aspx file has been renamed Alice.aspx and placed in the web's root folder.&lt;/p&gt;
&lt;p&gt;How about this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Url&lt;span&gt;   &lt;/span&gt;TO: Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Simple&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Sample.aspx&lt;/span&gt;&amp;quot; &lt;span style="color:red"&gt;Name&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Books/Alice.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Now one could browse to &lt;a href="http://intranet/Books/Alice.aspx"&gt;http://intranet/Books/Alice.aspx&lt;/a&gt; - the Sample.aspx file has been renamed Alice.aspx, and a folder (Books) has been automatically provisioned to contain it. How about this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Path&lt;span&gt;   &lt;/span&gt;TO: Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Simple&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Books/Alice.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Path&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages\Sample.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;One could still browse to &lt;a href="http://intranet/Books/Alice.aspx"&gt;http://intranet/Books/Alice.aspx&lt;/a&gt;, but the original file is now found in the BookPages folder under the Feature folder. This is typically what one would see in Visual Studio, except that it would default the Url attribute to BookPages/Sample.aspx. What if one tried using Path, Name, and Url in the same File element?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Path&lt;span&gt;   &lt;/span&gt;TO: Name&lt;span&gt;  &lt;/span&gt;(Url is ignored) &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages\Sample.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Books/Alice.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Books/Fiction/Alice.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Name wins! This will provision Alice.aspx and two nested folders, so that one can browse to &lt;a href="http://intranet/Books/Fiction/Alice.aspx"&gt;http://intranet/Books/Fiction/Alice.aspx&lt;/a&gt;. The Url attribute is ignored - but remember it cannot be removed, it is required, and it cannot be empty. Clearly this is not an optimal situation; a better practice would be choosing Url+Name attributes or Url+Path attributes, but not all three.&lt;/p&gt;
&lt;p&gt;A couple of other attributes for the File element deserve special attention. Contemplate the attribute &lt;strong&gt;IgnoreIfAlreadyExists&lt;/strong&gt;. Sounds like that means one can overwrite an already provisioned file, but nope, that's wrong. IgnoreIfAlreadyExists is Boolean, and if set to True, the Module will not throw an exception if it encounters an existing file. If IgnoreIfAlreadyExists is not present, or is set to False, and the Module encounters an existing file, it &lt;em&gt;will&lt;/em&gt; throw an exception. So, if you'd rather not be notified that the Module failed to provision a file because the file was already there, set IgnoreIfAlreadyExists=&amp;quot;True&amp;quot;. Maybe it should be renamed &lt;strong&gt;DontThrowExceptionIfFileAlreadyExists&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Path&lt;span&gt;   &lt;/span&gt;TO: Name&lt;span&gt;  &lt;/span&gt;(Url is ignored) &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages\Sample.aspx&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;.&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Books/Fiction/Alice.aspx&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;IgnoreIfAlreadyExists&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;TRUE&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Why would the file already be there? Because Modules do not clean up behind themselves; they provision when the Feature is activated, but do not un-provision when it deactivates. Typically the FeatureDeactivating method is used to clean up files left lying around by Modules. Then the coast is clear for a new provisioning. Of course, if the business user has made customizations through the browser, those will be lost - so there may be times when that mysterious IgnoreIfAlreadyExists=&amp;quot;True&amp;quot; attribute is useful.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Visual Studio quietly takes care of deployment conflicts (like the file already exists) by default. Watch the Output window when deploying a Module Feature the second time, and you'll see something like &lt;span style="line-height:115%;font-family:'Calibri','sans-serif';font-size:11pt"&gt;&amp;quot;&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:11pt"&gt;Found 1 deployment conflict(s).&lt;span&gt;  &lt;/span&gt;Resolving conflicts ...Deleted file 'http://intranet/Books/Fiction/Alice.aspx' from server.&lt;/span&gt;&lt;span style="line-height:115%;font-family:'Calibri','sans-serif';font-size:11pt"&gt;&amp;quot;&lt;/span&gt; This is great for development, but be aware that in production, re-activating a Feature with a Module will throw an exception if there's been no cleanup of those files orphaned by the Module. This Visual Studio behavior can be controlled by the Deployment Resolution Conflict property on a Module's folder. In Solution Explorer, select the Module folder, then peek in the Properties window.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;GhostableInLibrary and Ghostable&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let's look at provisioning to a List - a specialized List known as a Document Library in this case:&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;List&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;101&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Docs&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Path&lt;span&gt;   &lt;/span&gt;TO: Url+Url &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages\Sample.aspx&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Alice.aspx&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Type&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;GhostableInLibrary&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&lt;img alt="Module deploys to Document Library" src="/NancyB/Lists/Photos/ModuleDocLibrary.png"&gt;&lt;/p&gt;
&lt;p&gt;The File element has sprouted another attribute, Type=&amp;quot;GhostableInLibrary&amp;quot;. If this is left off, the file will not provision to the Library. Remember the old SharePoint terms &amp;quot;ghosted&amp;quot; and &amp;quot;unghosted&amp;quot;? Yep, this hearkens back to those older terms, and specifies that the file provisions to a Library, and is cached. The List attribute in the Module element is not required, but it can help alert one to a missing library. Without it, SharePoint will merrily create a folder if no such library exists at the Module's Url. With it, SharePoint will throw an exception if there's no library. (A spurious folder when one expected a Library can be hard to troubleshoot.) The number 101 in List=&amp;quot;101&amp;quot; is the List Template Type. For a listing of List Template Types, see &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splisttemplatetype.aspx"&gt;SPListTemplateType Enumeration&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The final Url is now a concatenation of the Module's Url attribute (which is the List's Url) and the File's Url attribute (which is the final name of the file), so one can browse to &lt;a href="http://intranet/Docs/Alice.aspx"&gt;http://intranet/Docs/Alice.aspx&lt;/a&gt;, and see the file in the Library Docs. The Module element can also have a Path attribute, which prefixes any Path attribute in the File element.&lt;/p&gt;
&lt;p&gt;Take a look at this variation which uses the Path attribute in the Module element to provision a folder in the Library, and stuffs Alice.aspx in it, resulting in a Url of &lt;a href="http://intranet/Docs/Books/Alice.aspx"&gt;http://intranet/Docs/Books/Alice.aspx&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;List&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;101&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Docs/Books&lt;/span&gt;&amp;quot;&lt;/b&gt;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Path&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Path+Path&lt;span&gt;   &lt;/span&gt;TO: Url+Url &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Sample.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Alice.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Type&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;GhostableInLibrary&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;/&amp;gt;&lt;span&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;&lt;img alt="Module deploys to Document Library Folder" src="/NancyB/Lists/Photos/ModuleDocLibraryFolder.png"&gt;&lt;/p&gt;
&lt;p&gt;But what about the &lt;strong&gt;Type=Ghostable &lt;/strong&gt;attribute?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;List&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;101&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Docs&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: Path&lt;span&gt;   &lt;/span&gt;TO: Url+Url &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages\Sample.aspx&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Alice.aspx&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Type&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Ghostable&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;/&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;Switching to &lt;strong&gt;Type=&amp;quot;Ghostable&amp;quot;&lt;/strong&gt; &lt;em&gt;creates a &amp;quot;Docs&amp;quot; &lt;strong&gt;folder&lt;/strong&gt; &lt;/em&gt;at &lt;a href="http://intranet/Docs"&gt;http://intranet/Docs&lt;/a&gt;, with Alice.aspx inside it, and now again one can browse to &lt;a href="http://intranet/Docs/Alice.aspx"&gt;http://intranet/Docs/Alice.aspx&lt;/a&gt;. Since there's already a Library at &lt;a href="http://intranet/Docs"&gt;http://intranet/Docs&lt;/a&gt;, this could be seriously confusing.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Yikes!! I Document Library and Folder with the same Url" src="/NancyB/Lists/Photos/ModuleDocLibAndPath.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SetupPath, Sandboxed Solutions, and the Visual Studio view&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There's one more Module attribute to mention: &lt;strong&gt;SetupPath&lt;/strong&gt;. Pick Path OR SetupPath, but not both. SetupPath is the physical path to a folder which is relative to &lt;strong&gt;{SharePointRoot}\TEMPLATE&lt;/strong&gt;, so it's a way to reference files in folders there or below. If you inadvertently include both, SetupPath will win. Want to grab Default.aspx from the Team Site definition and add it to the Docs Library as Nathan.aspx?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;BookPages&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;List&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;101&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Docs&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;SetupPath&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;SiteTemplates/STS&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt; FROM: SetupPath+Path&lt;span&gt;   &lt;/span&gt;TO: Url+Url &lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;--&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Nathan.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Type&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;GhostableInLibrary&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;/&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt;text-autospace:" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;&lt;img alt="Module SetupPath" src="/NancyB/Lists/Photos/ModuleSetupPath.png"&gt;&lt;/p&gt;
&lt;p&gt;So far, this has all been based on Farm Solutions, which write to the {SharePointRoot}\TEMPLATE\FEATURES\ folder, because one can see the Feature structure there easily. Recall that the Path attribute in a Module Element (Module) is relative to the {SharePointRoot}\TEMPLATE\Features\&lt;em&gt;FeatureName&lt;/em&gt; folder. Modules work the same way in Sandboxed Solutions, but the Feature Folder structure is inside the WSP.&lt;/p&gt;
&lt;p&gt;Switching a project from Farm Solution to Sandboxed Solution needs a little care, as Visual Studio is caching a bunch of stuff. First deactivate all Features in the Solution, then retract the Farm Solution, which removes the files from the {SharePointRoot}\TEMPLATE\FEATURES\ folder, the GAC, etc. Flip the Project's Sandboxed Solution property to TRUE, and close Visual Studio, flushing the cache. Reopen Visual Studio and redeploy. Now the WSP is in the Solutions Gallery. On the site, choose Site Actions &amp;gt; Site Settings &amp;gt; Solutions to navigate to the Solutions Gallery, or just open Visual Studio's bin/debug folder in Windows Explorer to see it there. Peering inside the WSP is easy with the Expand command.&lt;/p&gt;
&lt;p&gt;In a command prompt window, type:&lt;/p&gt;
&lt;blockquote style="margin-right:0px" dir=ltr&gt;
&lt;p&gt;expand  [PathToWSP]  -f:*  [PathToDestinationFolderForExpandedWSP]&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The -f:* switch says expand &lt;em&gt;all&lt;/em&gt; the folders and files inside the WSP. The Destination folder must already exist.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Expand cmd" src="/NancyB/Lists/Photos/ModuleExpandCmd.png"&gt;&lt;/p&gt;
&lt;p&gt;The Feature structure inside the Cabinet file, (the WSP), is the same as it would be in the {SharePointRoot}\TEMPLATE\FEATURES folders for a Farm Solution:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Feature Folder structure inside a WSP" src="/NancyB/Lists/Photos/ModuleWSP.png"&gt;&lt;/p&gt;
&lt;p&gt;This is not so easy to see in the Solution Explorer in Visual Studio:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Visual Studio view of Features and Modules" src="/NancyB/Lists/Photos/ModuleVisualStudio.png"&gt;&lt;/p&gt;
&lt;p&gt;Bear in mind that when deployed, all those Visual Studio folders containing Elements.xml files will end up inside a Feature folder. There's more to Modules, but I hope this has de-mystified the basics. Happy coding!&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2012/02/29/Module-Element-(Module)-101.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>SharePoint REST, Concurrency Conflicts, and Persisting Changes</title><guid>/NancyB/archive/2012/01/25/SharePoint-REST,-Concurrency-Conflicts,-and-Persisting-Changes.aspx</guid><link>/NancyB/archive/2012/01/25/SharePoint-REST,-Concurrency-Conflicts,-and-Persisting-Changes.aspx</link><pubDate>Wed, 25 Jan 2012 16:18:00 GMT</pubDate><description>&lt;div class=ExternalClassDEA42C74F72A43FC9689A0961690C566&gt;
&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div&gt;What's a concurrency conflict? Picture this: Zach fires up a WPF application that does CRUD operations on a SharePoint List, the app loads a bunch of List Items, then Zach pauses to answer the phone. Two seconds later, Rebekah browses to that same SharePoint List, and updates Item 3. Zach gets off the phone, updates the same item in the same list, and clicks the Save button. (There was a little office miscommunication.) The WPF app detects a concurrency conflict - the item it is trying to update has changed since the app read it from the server.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;How are these concurrent updates handled? Typically there are two kinds of concurrency options: pessimistic and optimistic. Pessimistic concurrency involves locking the entity being updated, so that nothing else can change it until after the current update operation finishes. Optimistic concurrency does not lock the entity being updated, so it is possible that the entity on the server changed in the time between reading it from the server's data source and attempting the update, resulting in a concurrency conflict.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;SharePoint REST supports optimistic concurrency, and monitors concurrency conflicts by ETags, which are sort of like version numbers. (ETags, or Entity Tags, are part of the HTTP protocol: &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11"&gt;http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11&lt;/a&gt;) When the ETag in a WPF application (or Windows Forms or Silverlight or …) does not match the ETag in the REST service, that's a concurrency conflict. Sometimes changes should be pushed through, even if such conflicts exist. In SharePoint REST, there are at least a couple of different persist-in-spite-of-concurrency-conflicts scenarios that might occur.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The first scenario occurs when there are detached entities- entities that are not part of a Data Context collection- the client ETag can be set to * with an overload of the Data Context AttachTo method. The REST service will interpret the * ETag from the client as a &amp;quot;we don't care about any concurrency conflicts&amp;quot; message, and do the update. Detached entities typically occur when there is no query filling the collection. Instead, perhaps a list of known IDs is passed to some method, and it creates entities for existing List Items, then attaches them to a Data Context collection for updating purposes. That could look something like this for a SharePoint List called ProjectMembers:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:#2b91af"&gt;OperationsDataContext&lt;/span&gt; ctx = &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;OperationsDataContext&lt;/span&gt;(&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;http://intranet/operations/_vti_bin/ListData.svc&amp;quot;&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;ctx.Credentials = &lt;span style="color:#2b91af"&gt;CredentialCache&lt;/span&gt;.DefaultCredentials;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:#2b91af"&gt;ProjectMembersItem&lt;/span&gt; pmi = &lt;span style="color:#2b91af"&gt;ProjectMembersItem&lt;/span&gt;.CreateProjectMembersItem(10);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;pmi.ProjectID = 4;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:green;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;// Set various properties...&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;ctx.MergeOption = &lt;span style="color:#2b91af"&gt;MergeOption&lt;/span&gt;.OverwriteChanges;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;ctx.AttachTo(&lt;span style="color:#a31515"&gt;&amp;quot;ProjectMembers&amp;quot;&lt;/span&gt;, pmi, &lt;span style="color:#a31515"&gt;&amp;quot;*&amp;quot;&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;ctx.UpdateObject(pmi);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;ctx.SaveChanges();&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Exception ex&lt;/span&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// network conditions, server availability...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The Data Context's MergeOption setting determines what happens when the SaveChanges method is called. Merge option OverwriteChanges causes all current values in the client collection, (ProjectMembers in this example), to be overwritten with fresh data from the REST service, effectively syncing what's already in the local collection with the data source. This overload of the AttachTo method adds a detached entity to the Data Context collection, and sets the ETag value. Since the Data Context was not tracking this entity before, (but it is now), UpdateObject is called to explicitly set the freshly attached entity's state to Modified.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Note that the DataContext method AttachTo is used for &lt;em&gt;existing&lt;/em&gt; entities, which can be modified or deleted. In the proxy classes created by adding a service reference, there are methods with the naming convention AddTo&lt;em&gt;ListName&lt;/em&gt;, like AddToProjectMembers for the ProjectMembers List. These methods are wrappers for the Data Context's AddObject method, which creates a brand new entity in the Data Context collection, ready to be inserted in the data source.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The second scenario involves a Data Context collection that has been filled by a query. In that case, persisting updates in spite of concurrency conflicts looks a bit different. Consider this demo WPF application, which updates a SharePoint List called Members; just a DataGrid, a button, and a TextBlock.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="WPF application demos SharePoint REST" src="/NancyB/Lists/Photos/RESTConcurrency_WPF.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's the initial load code, with the query using a view projection to grab just two columns for updating purposes:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:#2b91af"&gt;OperationsDataContext&lt;/span&gt; ctx = &lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:#2b91af"&gt;IQueryable&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;MembersItem&lt;/span&gt;&amp;gt; query = &lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:#2b91af"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;MembersItem&lt;/span&gt;&amp;gt; members = &lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; MainWindow()&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;InitializeComponent();&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;ctx = &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;OperationsDataContext&lt;/span&gt;(&lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;http://intranet/operations/_vti_bin/ListData.svc&amp;quot;&lt;/span&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;ctx.Credentials = &lt;span style="color:#2b91af"&gt;CredentialCache&lt;/span&gt;.DefaultCredentials;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;query = &lt;span style="color:blue"&gt;from&lt;/span&gt; m &lt;span style="color:blue"&gt;in&lt;/span&gt; ctx.Members&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;              &lt;/span&gt;&lt;span style="color:blue"&gt;select&lt;/span&gt; &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;MembersItem&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;              &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                &lt;/span&gt;MemberName = m.MemberName,&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;                &lt;/span&gt;LoginName = m.LoginName&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;              &lt;/span&gt;};&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;members = &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;MembersItem&lt;/span&gt;&amp;gt;(query);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;dataGrid1.ItemsSource = members;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;When this first loads, the Data Context begins tracking all the entities loaded by the query, which means they have ETags already, they are already attached to the collection, and their state is Unchanged. Since the Data Context collection provides change tracking, the entity state for each item will be automatically updated to Modified, Deleted, or Added as the business user makes changes in the WPF application. In order for any of these updates to be applied by the SharePoint REST Service, the ETags in this local collection have to match the ETags in the service.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;When a concurrency conflict occurs in this situation, it is possible to reload the local collection from the REST service, updating the ETags, but preserving the changes that were made in the client, so the ETags in the client collection match the service ETags, and the update can be tried again. Unless another concurrency conflict occurs, (not likely, but possible), a second call to SaveChanges() after that reload will probably push all changes through, except for Delete operations on already-deleted entities. If that WPF app attempts to delete an entity, but somebody else already deleted it on the server, the delete operation can fail on both first and second attempts, leaving the deleted entity hanging around in the local collection. So, after a second attempt to push through updates, it may be reasonable to just refresh the local collection.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The Data Context's MergeOption controls how queries load the local collection, as well as how SaveChanges updates that local collection. It is set to a value in the enumeration System.Data.Services.Client.MergeOption: AppendOnly, PreserveChanges, OverwriteChanges, NoTracking. The &lt;strong&gt;Save Changes and Refresh &lt;/strong&gt;button code from the WPF app demonstrates this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;private&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; saveButton_Click(&lt;span style="color:blue"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af"&gt;RoutedEventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// If all updates complete successfully, a response object will be returned&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:#2b91af"&gt;DataServiceResponse&lt;/span&gt; response = ctx.SaveChanges(&lt;span style="color:#2b91af"&gt;SaveChangesOptions&lt;/span&gt;.ContinueOnError);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.textBlock1.Text = &lt;span style="color:#a31515"&gt;&amp;quot;Update successful!&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;DataServiceRequestException&lt;/span&gt; dse)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// If any update fails, the response object can be found &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// as a property of the DataServiceRequestException &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;foreach&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;ChangeOperationResponse&lt;/span&gt; cor &lt;span style="color:blue"&gt;in&lt;/span&gt; dse.Response)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:green"&gt;// if details are needed, process each ChangeOperationResponse&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// Try to persist updates, ignoring concurrency conflicts&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// Execute query again, getting fresh data from OData service,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// preserving any uncommitted changes in the local collection (members),&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// and refreshing ETags&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;ctx.MergeOption = &lt;span style="color:#2b91af"&gt;MergeOption&lt;/span&gt;.PreserveChanges;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;members = &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;MembersItem&lt;/span&gt;&amp;gt;(query);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.dataGrid1.ItemsSource = members;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:#2b91af"&gt;DataServiceResponse&lt;/span&gt; response = ctx.SaveChanges(&lt;span style="color:#2b91af"&gt;SaveChangesOptions&lt;/span&gt;.ContinueOnError);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.textBlock1.Text = &lt;span style="color:#a31515"&gt;&amp;quot;All updates persisted&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;DataServiceRequestException&lt;/span&gt; dse2)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:green"&gt;// It is unlikely, but possible, that more concurrency conflicts occurred.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:green"&gt;// However, an attempt to delete a List Item that is already deleted&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:green"&gt;// in SharePoint will create the DataServiceRequestException - but isn't &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:green"&gt;// really an issue, since the end result (deletion) is the same.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.textBlock1.Text = &lt;span style="color:#a31515"&gt;&amp;quot;Some updates may not have been persisted&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt; ex)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:green"&gt;// Other issues may cause errors - server availability, network&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.textBlock1.Text = &lt;span style="color:#a31515"&gt;&amp;quot;Unable to persist all updates. Error=\&amp;quot;&amp;quot;&lt;/span&gt; +&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;ex.Message + &lt;span style="color:#a31515"&gt;&amp;quot;\&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// Refresh local collection&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// Execute query again, getting fresh data from OData service,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// overwrite any lingering uncommitted changes in the DataGrid&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;ctx.MergeOption = &lt;span style="color:#2b91af"&gt;MergeOption&lt;/span&gt;.OverwriteChanges;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;members = &lt;span style="color:blue"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DataServiceCollection&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;MembersItem&lt;/span&gt;&amp;gt;(query);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.dataGrid1.ItemsSource = members;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// Set Merge Options back to default&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;ctx.MergeOption = &lt;span style="color:#2b91af"&gt;MergeOption&lt;/span&gt;.AppendOnly;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;Exception&lt;/span&gt; ex)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:green"&gt;// Other issues may cause errors - server availability, network&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.textBlock1.Text = &lt;span style="color:#a31515"&gt;&amp;quot;Unable to persist all updates. Error=\&amp;quot;&amp;quot;&lt;/span&gt; +&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;ex.Message + &lt;span style="color:#a31515"&gt;&amp;quot;\&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Another enumeration, SaveChangesOptions, can be used to tell the REST service whether to stop on the first error - that's the default, &lt;span style="line-height:115%;font-family:Consolas;color:#2b91af;font-size:9.5pt"&gt;SaveChangesOptions.&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:9.5pt"&gt;None&lt;/span&gt; - or to try all change operations in spite of errors, as in the code above, (&lt;span style="line-height:115%;font-family:Consolas;color:#2b91af;font-size:9.5pt"&gt;SaveChangesOptions&lt;/span&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:9.5pt"&gt;.ContinueOnError&lt;/span&gt;), or send the changes as a single batch, or use the PUT verb for updates. (MERGE is used by default.) If details of each change operation are needed, the DataServiceResponse object can be inspected. This is returned by the SaveChanges() method if all goes well, or found on the DataServiceRequestException exception if not. If it is needful to sort out which changes failed, any entity in the DataServiceResponse object with a state other than Unchanged denotes a failed operation.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;To see what happens in these exchanges, it can be helpful to check things out in the QuickWatch window. Set a break point and drill down into the Data Context object like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="QuickWatch window shows REST entities and ETags" src="/NancyB/Lists/Photos/RESTConcurrency_QuickWatch.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Another way to see what's happening is Fiddler2, a free and wonderful tool for web debugging (&lt;a href="http://www.fiddler2.com/fiddler2/"&gt;http://www.fiddler2.com/fiddler2/&lt;/a&gt;). In this screenshot, a successful update by the WPF app can be seen, with before (W/&amp;quot;12&amp;quot;) and after (W/&amp;quot;13&amp;quot;) ETags visible. When an update operations succeeds, the HTTP response is 204 No Content.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Fiddler2 shows REST update" src="/NancyB/Lists/Photos/RESTConcurrency_Fiddler2.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Happy RESTful coding!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2012/01/25/SharePoint-REST,-Concurrency-Conflicts,-and-Persisting-Changes.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>Trouble in the Sandbox: a Site-Scoped ItemDeleting Event Receiver</title><guid>/NancyB/archive/2011/12/20/Trouble-in-the-Sandbox[coln]-a-Site[dash]Scoped-ItemDeleting-Event-Receiver.aspx</guid><link>/NancyB/archive/2011/12/20/Trouble-in-the-Sandbox[coln]-a-Site[dash]Scoped-ItemDeleting-Event-Receiver.aspx</link><pubDate>Tue, 20 Dec 2011 05:36:00 GMT</pubDate><description>&lt;div class=ExternalClass425355A4DD8B4A2A8BFAC314D88FEB90&gt;
&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div class=ExternalClassAAE58308D5754F699B7A815359E2D6F7&gt;
&lt;div&gt;Sandboxed Solutions are a very cool, very new feature in SharePoint 2010, a &lt;em&gt;version 1.0&lt;/em&gt; feature. Translation: watch out for bugs.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;When a List Item Event Receiver is added to a SharePoint Project in a Sandboxed Solution, the associated Feature is automatically Web-scoped, and works as expected. But if the Feature scope is changed to Site, weird stuff happens. Let's consider the ItemDeleting event, which has extra weirdness.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The Visual Studio Event Receiver wizard has an Event Source dropdown for List Item Events:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="SharePoint Event Receiver Wizard" src="/NancyB/Lists/Photos/EventReceiverWizard.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;For a List Item Event, that event source is typically a &lt;em&gt;type&lt;/em&gt; of List, which is identified by a ListTemplateId attribute in the Receivers element:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Receivers Element showing ListTemplateId" src="/NancyB/Lists/Photos/EventReceiverElementsXml.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;With this setup in place, this Receiver will automatically be bound to all the Announcements-type lists in any Web where the Feature has been activated, and it will not apply to any other types of Lists. (Announcements Lists are type 104 - see the List Template Type enumeration for a rundown on these - &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splisttemplatetype.aspx"&gt;http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splisttemplatetype.aspx&lt;/a&gt;.)&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;In this example, the code will simply cancel the ItemDeleting event, and direct the business user to expire the Announcement instead. That code might look like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;override&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; ItemDeleting(&lt;span style="color:#2b91af"&gt;SPItemEventProperties&lt;/span&gt; properties)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;properties.Status = &lt;span style="color:#2b91af"&gt;SPEventReceiverStatus&lt;/span&gt;.CancelWithError;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;  &lt;/span&gt;properties.ErrorMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Please expire, rather than delete.&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;As long as the Feature remains at Web scope, this works as advertised - Announcements cannot be deleted, and business users are presented with the message to expire rather than delete:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Standard SharePoint error page with custom message" src="/NancyB/Lists/Photos/EventReceiverMessage.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Try changing to a Site-scoped Feature, and deployment succeeds the first time. But the very next deployment fails, with Visual Studio muttering (in the Output window) that retraction failed, so Visual Studio just quits right there, and throws up its hands (figuratively speaking). Curiously, this does not happen with the ItemAdding or ItemUpdating events. Weirdly, if one attempts to deploy again, (third time's a charm), the &amp;quot;retraction&amp;quot; succeeds (!?!), and deployment succeeds. Here's what happened: during the failed deployment, the Sandboxed Solution is &amp;quot;retracted&amp;quot; (that is, deactivated in the Solutions Gallery), then Visual Studio chokes on deleting it. The next time, the Solution is already deactivated, so Visual Studio just attempts to delete it, succeeds in deleting it, then succeeds in deploying the new Solution.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Does this Site-scoped version work? Yep, a little too well. Try to delete an Announcement, and voila, the deletion is blocked, and the message appears. Switch to another type of List, a Tasks List. Try to delete a Task item, and that deletion is blocked, and the message appears. Try to delete an item from any type of List, and the deletion is blocked. Oops. The ItemDeleting Event Receiver now applies to &lt;em&gt;every&lt;/em&gt; list, not just whatever was specified by the ListTemplateId attribute in the Receivers element in Elements.xml.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Remember that Event Source dropdown list in the Visual Studio Event Receiver wizard? Event Receivers are bound to Event Hosts, which are SharePoint objects: SPContentType, SPFile, SPList, SPListItem, SPWeb, SPSite, or SPWorkflow. (BTW,&amp;quot; bound&amp;quot; is just another way to say &amp;quot;registered&amp;quot;.) By poking around with PowerShell, one can see where an Event Receiver is bound. It turns out that when the Feature is Web-scoped, the Item Event Receiver is actually bound to individual Lists. When the Feature is Site-scoped, the Item Event Receiver is bound to the SPSite object. Here's the Web-scoped version as seen in the SharePoint 2010 Management Shell:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="PowerShell showing Event Receiver bound to List" src="/NancyB/Lists/Photos/EventReceiverWebScopePowerShell.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;And here's the Site-scoped version:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="PowerShell showing the Event Receiver bound to the SPSite object" src="/NancyB/Lists/Photos/EventReceiverSiteScopePowerShell.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;So, a simple workaround for the Site-scoped version is to filter the Lists in the Event Receiver code, like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;override&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; ItemDeleting(&lt;span style="color:#2b91af"&gt;SPItemEventProperties&lt;/span&gt; properties)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;base&lt;/span&gt;.ItemDeleting(properties);&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:green"&gt;// At the Site Scope, the event receiver is registered with &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:green"&gt;// the Site Collection, not with individual Lists,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:green"&gt;// so restrict it here&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (properties.List.BaseTemplate == &lt;span style="color:#2b91af"&gt;SPListTemplateType&lt;/span&gt;.Announcements)&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;properties.Status = &lt;span style="color:#2b91af"&gt;SPEventReceiverStatus&lt;/span&gt;.CancelWithError;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;properties.ErrorMessage = &lt;span style="color:#a31515"&gt;&amp;quot;Please expire, rather than delete.&amp;quot;&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;To alleviate the annoying deployment issue, use a PowerShell script as a pre-deployment command to retract the Sandboxed Solution, leaving Visual Studio to just carry out the deletion. (Note: &amp;quot;Retract&amp;quot; is spelled &amp;quot;Uninstall&amp;quot; in PowerShell, hence the &amp;quot;Uninstall-SPUserSolution&amp;quot; below.) Here's the PreDeploy.ps1 PowerShell script:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;Add-PSSnapin &amp;quot;Microsoft.SharePoint.PowerShell&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;$wsp = &amp;quot;Mindsharp.ListItemEvent.SiteScope.wsp&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;$url = &amp;quot;http://intranet&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;Echo &amp;quot;&lt;span&gt;  &lt;/span&gt;Retracting Solution...&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;Uninstall-SPUserSolution $wsp -Site $url -Confirm:$False&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Pre-deployment commands are found on the SharePoint tab of the Project's properties. (Just double-click the Properties folder in Solution Explorer to see it.) Don’t forget to use the SysNative alias in the pre-deployment command, so that Visual Studio launches the right version of PowerShell:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="margin:0in 0in 10pt" class=MsoNormal&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:9pt"&gt;%WINDIR%\SysNative\WindowsPowerShell\v1.0\powershell.exe -command &amp;quot;&amp;amp; '$(ProjectDir)PreDeploy.ps1'&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt" class=MsoNormal&gt;&lt;span style="line-height:115%;font-family:Consolas;font-size:9pt"&gt;&lt;/span&gt;&lt;span style="line-height:115%;font-size:9pt"&gt;&lt;img alt="Pre-deployment command" src="/NancyB/Lists/Photos/EventReceiverPreDeployCommand.png"&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;More Trouble in the Sandbox: Feature Receiver code in a Site-scoped Item Event Receiver Solution&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;What if this Sandboxed Solution also needs Feature Receiver code? Typically, a Feature Receiver would just be added to the existing Feature. If this were Web-scoped, that would work. If this were a Farm Solution, that would work. However, in a Sandboxed Solution, adding a Feature Receiver to the existing Site-scoped Item Event Receiver Feature can cause the WSP to get stuck in the Solutions Gallery - really, really stuck - can't delete it from the browser, can't delete using PowerShell. (Weirdly, it can be activated and deactivated.) Manual intervention can fix this.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;To unstick the stuck WSP, save the Feature Receiver code somewhere, then delete the Feature Receiver. Build and package the solution (these options are on the Build menu). If the Solution's configuration is Debug, the newly packaged WSP will be in the Solution's bin/debug folder. Use the Show All Files button to see it in the Solution Explorer.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Solution Explorer showing WSP" src="/NancyB/Lists/Photos/EventReceiverWSPinSolutionExplorer.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Browse to the Solutions Gallery, and upload the just-packaged WSP, (the one with no Feature Receiver code), &lt;strong&gt;overwriting &lt;/strong&gt;the existing &amp;quot;stuck&amp;quot; WSP. Then deactivate and delete the WSP using the Ribbon.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;With the stuck WSP out of the way, go back to Visual Studio, and add a new Site-scoped Feature, then add the Feature Receiver code to the new Feature. This should take care of the &amp;quot;stuck WSP&amp;quot; issue, and allow normal iterative development to keep flowing.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Hope that helps!&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2011/12/20/Trouble-in-the-Sandbox[coln]-a-Site[dash]Scoped-ItemDeleting-Event-Receiver.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>Provisioning Web Parts in a DIY Sandboxed WebTemplate</title><guid>/NancyB/archive/2011/11/08/Provisioning-Web-Parts-in-a-DIY-Sandboxed-WebTemplate.aspx</guid><link>/NancyB/archive/2011/11/08/Provisioning-Web-Parts-in-a-DIY-Sandboxed-WebTemplate.aspx</link><pubDate>Tue, 08 Nov 2011 04:56:00 GMT</pubDate><description>&lt;div class=ExternalClass3EEFAC5102B548448E579E69A740055D&gt;&lt;table style="font-size:1.2em"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=800&gt;
&lt;div&gt;The new (2010) way to create custom site definitions is the Web Template, which is Sandbox-safe. These can be created using the Save-site-as-template on the Site Settings page, but that creates a humongous beast containing all the Fields, Content Types, Lists… way more stuff than is truly needed, so a better solution is the Do-It-Yourself (DIY) WebTemplate.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;A DIY Sandboxed WebTemplate solution might look like this in Solution Explorer, with a Site Feature to deploy the WebTemplate to the Solutions Gallery, and another hidden Feature, (WebFeature in this case), to handle the custom provisioning of a new site.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Solution Explorer for Custom Web Template" src="/NancyB/Lists/Photos/FRED_WebTemplate_SolutionExplorer.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;This post is about just one aspect of this scenario: how to provision web parts to a page using a provisioning Feature in a Sandboxed WebTemplate Solution. The page in this example is default.aspx, a clone of the STS#1 (Blank Site) default.aspx, with some added text and an image. SiteFeature deploys the actual Web Template - that's everything in the FRED folder: ONet.xml and Elements.xml (which contains only a WebTemplate element). WebFeature deploys everything in the ProvisionModule folder: default.aspx and Elements.xml, which contains such bits as ListInstance elements, Modules, and PropertyBag elements. WebFeature is called by ONet.xml to help provision a new site.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;List View Web Parts&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Typically, the ONet.xml file for a Do-It-Yourself WebTemplate is created by selectively copying/pasting from the base site definition's ONet.xml. This could lead one to thinking &amp;quot;Oh, I’ll just grab the &amp;lt;List&amp;gt; elements too.&amp;quot; Unfortunately, that won't work. Well, specifying the &amp;lt;List&amp;gt; element in ONet.xml &lt;em&gt;will &lt;/em&gt;create the list, but if a &amp;lt;View&amp;gt; element is used in the provisioning Feature's xml to create the matching web part, that fails with this sort of error message in the log:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="font-family:Consolas"&gt;&lt;font size=3&gt;Failed to find a suitable list id for doc 'default.aspx' given List template attribute 'Lists/Announcements'.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 10pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas"&gt;&lt;font size=3&gt;Failed with 0x80004005 to create the view query or web parts for web /fred, site collection (unspecified), URL default.aspx&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt;Solution - instead of using &amp;lt;List&amp;gt; in ONet.xml, use the new ListInstance element in the provisioning Feature (WebFeature in this example). Looks like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;xml&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;version&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;encoding&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Elements&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;xmlns&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;ListInstance&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;FeatureId&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;{00bfea71-d1ce-42de-9c63-a44004ce0104}&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;TemplateType&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;104&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Title&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Announcements&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Description&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Lists/Announcements&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;OnQuickLaunch&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;TRUE&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;RootWebOnly&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;FALSE&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Data&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Rows&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Row&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Field&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Title&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;Keep the Team Up-To-Date!&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Field&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Field&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Body&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;Use this List to post any SharePoint 2010 tips or tricks&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Field&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Field&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Expires&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;12/31/2011&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Field&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Row&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Rows&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Data&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;ListInstance&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ProvisionModule&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ProvisionModule\default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Type&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Ghostable&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;View&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;List&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Lists/Announcements&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;BaseViewID&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;1&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WebPartOrder&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;0&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;WebPartZoneID&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Left&lt;/span&gt;&amp;quot; &lt;span style="color:blue"&gt;&amp;gt;&lt;span&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;View&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Elements&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;Other web parts, with customizations&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;There are at least a couple of options here. Both involve customizing a web part through the browser, and then harvesting that customization somehow. Option one is exporting the customized web part and using that data in an AllUsersWebPart element. Option two is using the Save-site-as-template to create a WSP that is then imported into Visual Studio, followed by extracting the BinarySerializedWebPart element from it.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;  &lt;strong&gt;AllUsersWebPart&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;First customize a web part through the browser. The image web part is pretty straightforward, and we can use images in the {SharePointRoot} images folder, so let's use that. For option one, the AllUsersWebPart, we'll set the web part to show templogo.gif, left-justified, with no chrome and no title, then use the Export option.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Export an Image Web Part" src="/NancyB/Lists/Photos/FRED_ExportImageWebPart.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Open the exported .dwp or .webpart file in Notepad, and copy the entire WebPart element. The opening WebPart tag only needs the xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/"&gt;http://schemas.microsoft.com&lt;/a&gt;…&amp;quot; attribute, so delete any others. Usually it is best also to delete the child elements that are default values as well. In the provisioning Feature's Elements.xml, add an AllUsersWebPart element with a CDATA section to contain the WebPart element just created from the export. (The AllUsersWebPart element can &amp;quot;host&amp;quot; almost every web part.) Note that the WebPartZoneID and WebPartOrder should be attributes of the AllUsersWebPart element, not child elements of the WebPart element. The AllUsersWebPart is added as a child element to the File element, just like the View element in the example above. The AllUsersWebPart should look something like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;AllUsersWebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WebPartZoneID&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Left&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;WebPartOrder&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;![CDATA[&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;WebPart xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;Title /&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;FrameType&amp;gt;None&amp;lt;/FrameType&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;FrameState&amp;gt;Normal&amp;lt;/FrameState&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;MissingAssembly&amp;gt;Cannot import this Web Part.&amp;lt;/MissingAssembly&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;Assembly&amp;gt;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;lt;/Assembly&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;TypeName&amp;gt;Microsoft.SharePoint.WebPartPages.ImageWebPart&amp;lt;/TypeName&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;ImageLink xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;/_layouts/images/templogo.gif&amp;lt;/ImageLink&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;VerticalAlignment xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;Middle&amp;lt;/VerticalAlignment&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;HorizontalAlignment xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;Left&amp;lt;/HorizontalAlignment&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;/WebPart&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;]]&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;AllUsersWebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;  &lt;strong&gt;BinarySerializedWebPart&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Going back to the site where the image Web Part was customized earlier, let's add another web part, an XML Viewer, and use it to display the first five titles in a blog - that means adding some XSL. The XML Viewer Web Part is a bit different from most other web parts - one of its properties is an XSL transform. That means if one exports it, there is already a CDATA section in the XML. Here's an example with the embedded CDATA section highlighted:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;WebPart xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2&amp;quot;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;Title&amp;gt;XML Viewer&amp;lt;/Title&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;FrameType&amp;gt;Default&amp;lt;/FrameType&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;Description&amp;gt;Transforms XML data using XSL and shows the results.&amp;lt;/Description&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;ZoneID&amp;gt;Left&amp;lt;/ZoneID&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;PartOrder&amp;gt;0&amp;lt;/PartOrder&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;FrameState&amp;gt;Normal&amp;lt;/FrameState&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;MissingAssembly&amp;gt;Cannot import this Web Part.&amp;lt;/MissingAssembly&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;Assembly&amp;gt;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;lt;/Assembly&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;TypeName&amp;gt;Microsoft.SharePoint.WebPartPages.XmlWebPart&amp;lt;/TypeName&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;XMLLink xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Xml&amp;quot;&amp;gt;http://www.tinyurl.com/SPTeamBlog&amp;lt;/XMLLink&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;XML xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Xml&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;XSLLink xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Xml&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;XSL xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Xml&amp;quot;&amp;gt;&lt;b&gt;&lt;span style="background:aqua"&gt;&amp;lt;![CDATA[&lt;/span&gt;&lt;/b&gt;&lt;span style="background:aqua"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;xsl:stylesheet version=&amp;quot;1.0&amp;quot; xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;xsl:output method=&amp;quot;html&amp;quot; indent=&amp;quot;yes&amp;quot;/&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;xsl:param name=&amp;quot;TITLE&amp;quot;/&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;xsl:template match=&amp;quot;rss&amp;quot;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;div style=&amp;quot;background:#ffffff; padding:0; font-size:10px;&amp;quot;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;xsl:for-each select=&amp;quot;channel/item[position() &amp;amp;lt; 6]&amp;quot;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;a href=&amp;quot;{link}&amp;quot; target=&amp;quot;_new&amp;quot;&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;title&amp;quot;/&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/div&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;span style="background:aqua"&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;/xsl:template&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span style="background:aqua"&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;b&gt;]]&amp;gt;&lt;/b&gt;&lt;/span&gt;&amp;lt;/XSL&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;PartStorage xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Xml&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin:0in 0in 0pt" class=MsoNoSpacing&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;&amp;lt;/WebPart&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;CDATA sections cannot be nested, so the AllUsersWebPart element is not much help here; but a BinarySerializedWebPart can be. Create a WSP for that site using the Save-site-as-template option on the Site Settings page. In the Solutions Gallery, click the name of the solution to download a copy to the hard drive. Fire up Visual Studio, and create a new Import SharePoint Solution Package project. Import the solution just downloaded, taking all the defaults. In Solution Explorer, expand the Modules folder, and find a folder that starts with &amp;quot;_SiteTemplates&amp;quot; - that's where the BinarySerializedWebPart will be. (In this example, the Site used for the web parts is a Blank Site - STS#1). Double-click Elements.xml to view it in the Visual Studio editor.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="BinarySerializedWebPart XML" src="/NancyB/Lists/Photos/FRED_BinarySerializedWebPart.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Copy the entire BinarySerializedWebPart element, and paste it inside the File element as before. Be sure to edit the Url attribute to match the deployment scenario, which in this case, would be just &amp;quot;default.aspx&amp;quot;, and don't forget to update the WebPartOrder and WebPartZoneId attributes. The Module element with these three web parts now looks like this:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Name&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ProvisionModule&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Path&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;ProvisionModule\default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Url&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Type&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Ghostable&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;View&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;List&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Lists/Announcements&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;BaseViewID&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;1&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WebPartOrder&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;0&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;WebPartZoneID&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Left&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;View&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;AllUsersWebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WebPartZoneID&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Left&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;WebPartOrder&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;1&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;![CDATA[&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;WebPart xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;Title /&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;FrameType&amp;gt;None&amp;lt;/FrameType&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;FrameState&amp;gt;Normal&amp;lt;/FrameState&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;MissingAssembly&amp;gt;Cannot import this Web Part.&amp;lt;/MissingAssembly&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;Assembly&amp;gt;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&amp;lt;/Assembly&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;TypeName&amp;gt;Microsoft.SharePoint.WebPartPages.ImageWebPart&amp;lt;/TypeName&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;ImageLink xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;/_layouts/images/templogo.gif&amp;lt;/ImageLink&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;AlternativeText xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;Temp Logo&amp;lt;/AlternativeText&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;VerticalAlignment xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;Middle&amp;lt;/VerticalAlignment&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;            &lt;/span&gt;&amp;lt;HorizontalAlignment xmlns=&amp;quot;http://schemas.microsoft.com/WebPart/v2/Image&amp;quot;&amp;gt;Left&amp;lt;/HorizontalAlignment&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;          &lt;/span&gt;&amp;lt;/WebPart&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:gray;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;]]&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;AllUsersWebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;BinarySerializedWebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;GUIDMap&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; /&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;        &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;WebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt; &lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;ID&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;{d5d0e278-b7b8-4ca0-987a-08643cf85f50}&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WebPartIdProperty&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;List&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Type&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;0&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Flags&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;DisplayName&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;Version&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;2&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Url&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;default.aspx&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WebPartOrder&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;2&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;WebPartZoneID&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;Left&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;IsIncluded&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;span style="color:red"&gt;FrameState&lt;/span&gt;&lt;span style="color:blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt;0&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;WPTypeId&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;{1077a241-f086-1411-9623-a67ec78bc114}&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;SolutionId&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;{00000000-0000-0000-0000-000000000000}&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Assembly&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Class&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;Microsoft.SharePoint.WebPartPages.XmlWebPart&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;Src&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;AllUsers&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;AQUAAAACKgBJACkAAz4AAAIqAEoAKQADPQAAAQIAKQAD//80VHJhbnNmb3JtcyBYTUwgZGF0YSB1c2luZyBYU0wgYW5kIHNob3dzIHRoZSByZXN1bHRzLg8BIAApAAP//xsvX2xheW91dHMvaW1hZ2VzL21zeG1sbC5naWYPAVEAXQAD///EAWh0dHA6Ly9zaGFyZXBvaW50Lm1pY3Jvc29mdC5jb20vYmxvZy9fbGF5b3V0cy9mZWVkLmFzcHg/eHNsPTImd2ViPSUyRmJsb2cmcGFnZT0yMjY1NDg5Ny01MzU1LTQwOWItODZiNy0xOTI5NTViYjU3ZDgmd3A9NjhjODA0NWYtMzcyZC00Zjg3LTkzNTMtNzk5MzZhY2ZhZDQ4JnBhZ2V1cmw9JTJGYmxvZyUyRlBhZ2VzJTJGZGVmYXVsdCUyRWFzcHgPARQAXQAE///sAzw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04Ij8+DQo8eHNsOnN0eWxlc2hlZXQgdmVyc2lvbj0iMS4wIiB4bWxuczp4c2w9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvWFNML1RyYW5zZm9ybSI+DQo8eHNsOm91dHB1dCBtZXRob2Q9Imh0bWwiIGluZGVudD0ieWVzIi8+DQo8eHNsOnBhcmFtIG5hbWU9IlRJVExFIi8+DQo8eHNsOnRlbXBsYXRlIG1hdGNoPSJyc3MiPg0KICA8ZGl2IHN0eWxlPSJiYWNrZ3JvdW5kOiNmZmZmZmY7IHBhZGRpbmc6MDsgZm9udC1zaXplOjEwcHg7Ij4NCiAgICAgIDx4c2w6Zm9yLWVhY2ggc2VsZWN0PSJjaGFubmVsL2l0ZW1bcG9zaXRpb24oKSAmbHQ7IDZdIj4NCiAgICAgICAgPGEgaHJlZj0ie2xpbmt9IiB0YXJnZXQ9Il9uZXciPjx4c2w6dmFsdWUtb2Ygc2VsZWN0PSJ0aXRsZSIvPjwvYT48YnIvPg0KICAgICAgPC94c2w6Zm9yLWVhY2g+DQogIDwvZGl2Pg0KPC94c2w6dGVtcGxhdGU+DQo8L3hzbDpzdHlsZXNoZWV0Pg8P&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;                 &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;color:red;font-size:9.5pt"&gt;PerUser&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;=&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&amp;quot;&lt;span style="color:blue"&gt;AQUAAAACKgBJACkAAz4AAAIqAEoAKQADPQAAAQQAKQAD//8UU2hhcmVQb2ludCBUZWFtIEJsb2cPDw==&lt;/span&gt;&amp;quot;&lt;span style="color:blue"&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;      &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;BinarySerializedWebPart&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;    &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;File&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;span&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Consolas;font-size:9.5pt"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="line-height:normal;margin:0in 0in 0pt" class=MsoNormal&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&lt;span&gt;  &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-family:Consolas;color:#a31515;font-size:9.5pt"&gt;Module&lt;/span&gt;&lt;span style="font-family:Consolas;color:blue;font-size:9.5pt"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's a new site is created from that DIY WebTemplate, displaying the customized web parts on default.aspx.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Site created from Custom Web Template, with Web Parts" src="/NancyB/Lists/Photos/FRED_site.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Hope that helps!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2011/11/08/Provisioning-Web-Parts-in-a-DIY-Sandboxed-WebTemplate.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>The DIY Sandboxed Web Template Situation Comedy</title><guid>/NancyB/archive/2011/10/26/The-DIY-Sandboxed-Web-Template-Situation-Comedy.aspx</guid><link>/NancyB/archive/2011/10/26/The-DIY-Sandboxed-Web-Template-Situation-Comedy.aspx</link><pubDate>Wed, 26 Oct 2011 20:49:00 GMT</pubDate><description>&lt;div class=ExternalClassAE8E02A0E17541A4AAC7437A3FC68C2B&gt;
&lt;div&gt;If new to Visual Studio 2010, a few gotchas may get you when first starting to work with Do-It-Yourself (DIY) Sandboxed Web Templates, the preferred SharePoint 2010 way to create custom site definitions. (If using the Save-site-as-template version, this won't apply.)&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="Save site as template  (Site Settings page)" src="/NancyB/Lists/Photos/SaveSiteAsTemplate.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Web Templates created by the Save-site-as-template option on the Site Settings page are kinda like html emitted by MS Word – very faithful to the original object, way more &amp;quot;markup&amp;quot; than optimal for those who are looking for simple and clean. Manually created Web Template solutions can be simple and clean, and have two possible deployment scopes: Farm and Site. This post focuses on creating a Web Template Solution from scratch and Site-level deployment, since Sandboxed Solutions are welcome in the cloud. When doing so, it is possible to trip in a number of spots. If fact, it can feel like a situation comedy at times, as we follow the plight of a star-crossed default.aspx when it deploys (or doesn't), or deploys too many times, or gets deleted by accident.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;But first off, what can be learned from a Save-site-as-template version? Create one, import it to Visual Studio, and discover that the ONet.xml file consists basically of the NavBars element, and one Configuration element with its SiteFeatures and WebFeatures child elements. A simple and clean way to create a custom ONet.xml is to copy &amp;amp; paste portions from the base site definition's ONet.xml, and imitate the Save-site-as-template variety by copying just the NavBars element, and one Configuration element, with its Site and Web Features only. (It's actually a requirement - Web Template ONet.xml files may only have &lt;strong&gt;one&lt;/strong&gt; configuration element.)&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;If the Configuration element contains Module elements, probably delete them, and use a Feature instead. (Features can be versioned and upgraded.) Also, beware - not all &amp;quot;Module&amp;quot;s are the same. There's Module Element (Site) – the one in ONet.xml - and then there's Module Element (Module) – the one used in regular old Feature xml. Looking up Module Element (Site) on MSDN reveals that the Path attribute is &amp;quot;Optional Text. Specifies the physical path to the file set &lt;strong&gt;relative to %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates\&lt;em&gt;Site_Definition&lt;/em&gt;&lt;/strong&gt;&amp;quot;. OK, so that's just for grabbing the original core site definition files. Trying to bend this Module element into deploying a custom file in the solution, (like default.aspx), will result in the first Situation Comedy episode (SitCom # 0) - the &lt;em&gt;origina&lt;/em&gt;l file deploys, not the custom one.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;A simple custom (DIY) Sandboxed Web Template Solution needs just two Features and three basic files:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;a Site scoped Feature to deploy the WebTemplate to the Solutions Gallery, containing&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;an Elements.xml for the WebTemplate element, which says something like &amp;quot;Hi, my name is 'Fred' and I'm based on the 'BlahBlah' core site definition&amp;quot;&lt;/li&gt;
&lt;li&gt;an ONet.xml file in the same Visual Studio folder, which contains provisioning details&lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;a Web scoped Feature for custom provisioning&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;this provisioning Feature will be listed in ONet.xml; its Elements.xml file handles most of the customizations that make this site different from the base site&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&lt;img alt="Features and Files for a DIY Web Template" src="/NancyB/Lists/Photos/2FeaturesAnd3Files.png"&gt;&lt;/p&gt;
&lt;p&gt;Alrighty then, that Web scoped Feature needs to be Hidden and should not be activated by Visual Studio on deployment (the default), so in the Feature properties, set &lt;strong&gt;IsHidden&lt;/strong&gt; to True, and &lt;strong&gt;Activate on Default &lt;/strong&gt;to False…deploy…and what the heck?!? The Web Feature auto-activated anyway, accidentally customizing the Project's test site, Intranet, with a new default.aspx. Turns out the &lt;strong&gt;Activate on Default &lt;/strong&gt;property does not apply to Site and Web scoped Features. Bummer. So, go to the Project's properties, find the SharePoint tab, and set the &lt;strong&gt;Active Deployment Configuration &lt;/strong&gt;to &lt;strong&gt;No Activation&lt;/strong&gt;. Use a PowerShell post-deployment script to activate the Site Feature, or manually activate it. Open the site in SharePoint Designer to fix default.aspx. And save a copy - just in case.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Accidentally activating WebFeature and overwriting default.aspx " src="/NancyB/Lists/Photos/AccidentalWebFeatureActivation.png"&gt;&lt;/p&gt;
&lt;p&gt;OK, that's fixed up, try again…deploy. Browse over to the Intranet site, just to be sure that WebFeature didn't sneak by somehow… and Gaaaaah! Intranet displays a 404 Not Found. What happened? Look in the Output window, where Visual Studio narrates what it's doing. Hmmm… &lt;em&gt;Found 1 deployment conflict(s) … deleting &lt;/em&gt;&lt;a href="http://intranet/default.aspx"&gt;&lt;em&gt;http://intranet/default.aspx&lt;/em&gt;&lt;/a&gt; .... not good. Inspect the Module's properties in the properties window. Aha. Deployment Conflict Resolution is set to &lt;strong&gt;Automatic&lt;/strong&gt;. Change that to &lt;strong&gt;None&lt;/strong&gt;. Use SharePoint Designer [again] to fix the missing default.aspx. Good thing there was a backup copy of default.aspx.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Visual Studio mistakenly deletes default.aspx (apparent deployment conflict)" src="/NancyB/Lists/Photos/ModuleDeletion.png"&gt;&lt;/p&gt;
&lt;p&gt;Last gotcha: things that must match.&lt;/p&gt;
&lt;p&gt;The WebTemplate's BaseConfigurationID and Onet.xml's Configuration Id must match. If they don't, Visual Studio will complain:&lt;/p&gt;
&lt;p&gt;&lt;font face=Consolas&gt;&amp;quot;Error occurred in deployment step 'Add Solution': …The Mindsharp.WebTemplates.Research_SiteFeature\FRED\onet.xml file must contain a Configuration element whose ID attribute is equal to the BaseConfigurationID attribute declared in the WebTemplate element.&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Configuration IDs must match" src="/NancyB/Lists/Photos/ConfigurationIdsMustMatch.png"&gt;&lt;/p&gt;
&lt;p&gt;Finally, the WebTemplate element's Name attribute and the Folder name which contains the Elements.xml file must be identical - in this case, it's FRED.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Template and Folder names must match" src="/NancyB/Lists/Photos/TemplateAndFolderNamesMustMatch.png"&gt;&lt;/p&gt;
&lt;p&gt;Have fun creating DIY Web Templates!&lt;/p&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2011/10/26/The-DIY-Sandboxed-Web-Template-Situation-Comedy.aspx#Comments</comments><category>SharePoint 2010 Development</category></item><item><author>Nancy Brown</author><title>LINQ to SharePoint Extensions (Reprise) &amp; I Love LINQPad</title><guid>/NancyB/archive/2011/10/20/LINQ-to-SharePoint-Extensions-(Reprise)-[amp]-I-Love-LINQPad.aspx</guid><link>/NancyB/archive/2011/10/20/LINQ-to-SharePoint-Extensions-(Reprise)-[amp]-I-Love-LINQPad.aspx</link><pubDate>Thu, 20 Oct 2011 06:43:00 GMT</pubDate><description>&lt;div class=ExternalClass91CBA212F31E41F0BAE65F5BD2282033&gt;
&lt;div&gt;At SPC 2011 a couple weeks ago, I gave a short talk from the Mindsharp booth on extending LINQ to SharePoint to the ListItem's Attachments property and property bag - which was the subject of an earlier blog post. The example for the original blog post was taken from our Developer's Course, which is continually being revised. In order to make the code a bit smaller for the SPC talk, I extracted just the extension code, and created a simpler Application page for working with it. The slides and code from the SPC talk can be downloaded &lt;a href="https://mindsharp.com/default.aspx?premium=downloads&amp;amp;file=ExtendingLINQToSharePoint.zip"&gt;here&lt;/a&gt;, from our Free Resources section.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;If you are working with LINQ in any way, are just learning LINQ, would like to know LINQ better, would like a way to test LINQ queries without deploying some project somewhere, would like a C# scratch pad for testing short chunks of code, or an F# tutorial - well then, LINQpad is for you! It's all that and more.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;It's free!!! (There is also a not-free-version with IntelliSense.) There are two flavors - one targets .NET Framework 3.5, the other targets .NET Framework 4.0 - SharePoint Devs want both, of course. Get it here: &lt;a href="http://www.linqpad.net/"&gt;http://www.linqpad.net/&lt;/a&gt; To try out LINQ to SharePoint queries, you'll also need the LINQPad SharePoint driver from Codeplex: &lt;a href="http://linqpadsp2010driver.codeplex.com/"&gt;http://linqpadsp2010driver.codeplex.com/&lt;/a&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Here's what it looks like - resembles SQL Server Management Studio a bit - and queries can be saved in the same way. I wanted to see if I could try the extensions code in LINQPad, and I could, using the Static version of the SharePoint driver:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="LINQPad with SharePoint Driver" src="/NancyB/Lists/Photos/LINQPadWithSharePointDriver.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Want to see the translated CAML query? Click the SQL button on the bottom right pane.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Perhaps some LINQ to SQL queries need a bit of testing? LINQPad has an awesome extension method called Dump() which creates a visualization of whatever object calls it:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;img alt="LINQPad with SQL queries and Dump() extension method" src="/NancyB/Lists/Photos/ILoveLINQPad.png"&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Tutorials? LINQPad has a built-in tutorial for LINQPad and for LINQ and for F# and …  click the Samples tab in the bottom left corner to discover them all!&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Happy LINQ-ing!&lt;/div&gt;&lt;/div&gt;</description><comments>/NancyB/archive/2011/10/20/LINQ-to-SharePoint-Extensions-(Reprise)-[amp]-I-Love-LINQPad.aspx#Comments</comments><category /></item></channel></rss>