In the preceding few examples, we used LINQ to Objects to illustrate the query syntax of LINQ—in fact, the syntax is pretty similar regardless of which provider you’re using. For example, to retrieve a list of records from a table using LINQ to SQL, you’d write something like this:NorthwindDataContext context = new NorthwindDataContext()); var customers = from c in context.Customers where c.Name.Contains("n") select c;
Or to get a list of nodes from an XML document using LINQ to XML, you’d use something like this:XDocument loaded = XDocument.Load(@"C:users.xml"); var q = from u in loaded.Descendants("user") where u.Name.Contains("n") select u;
As you’ll see, the only major difference is in the way that the “table” is referenced. When we used LINQ to Objects, the “table” was simply the collection variable, whereas when using LINQ to SQL the “table” is actually a database table. To make this less confusing, this “table” object is commonly referred to as a gateway object, since technically it doesn’t necessarily represent a table—the way it’s used in the SQL-like syntax makes it seem like a table.
The gateway object for LINQ to SharePoint is Microsoft. Share Point . Linq. DataContext. The Data Context object exposes a number of methods and properties, of which the following are most significant for the purposes of this discussion:
Conflict resolution object relationships
TIPDepending on the profile of your application, you may find that you use LINQ most often for querying data as opposed to making changes. Furthermore, you’ll generally be making changes to a very small dataset, whereas you may be querying much larger datasets. In this situation, maintaining a separate Data Context object for updates is usually the most efficient approach. In effect, you’ll have one Data Context with object-tracking enabled that you can use for updates, and another with objecttracking disabled that you can use for queries.
Figure shows the relationship between the conflict resolution objects. Conflict resolution is covered in more detail later in this chapter in the section “Record Level Conflict Resolution.” I’ve covered the main functional elements of the gateway class for LINQ to SharePoint, and a few other objects are significant as well, such as Entity List, Entity Ref, and Entity Set.
I won’t cover these in detail since their operation is practically identical to similar objects used on other variants of LINQ; their usage will become apparent in the code samples that follow. The Data Context object has special significance since it provides the gateway to using standard LINQ syntax, although, as you’ll see when we look at SPMetal, generally the Data Context object isn’t used directly; instead, common practice is to create a number of derived classes that represent each list in the data structure.
Share Point 2010 Related Interview Questions
|Web Services Interview Questions||XML Interview Questions|
|Share Point 2010 Interview Questions||ASP.NET Interview Questions|
|Share Point Administration Interview Questions||BizTalk Admin Interview Questions|
|Microsoft Office SharePoint Server (MOSS) Interview Questions||Biztalk Server Interview Questions|
|Asp Dot Net Mvc 4 Interview Questions||Biztalk Esb Toolkit Interview Questions|
|InfoPath Interview Questions|
Share Point 2010 Tutorial
The Microsoft Sharepoint 2010 Platform
Developing With Sharepoint 2010
Presentation Layer Overview
Client Object Model
Infopath Forms Services
Enterprise Content Management
User Interface Customization
Application Services Overview
Service Application Framework
Word Automation Services
Data Access Overview
Linq To Sharepoint And Spmetal
Business Connectivity Services
User Profiles And Social Data
Packaging And Deployment Model
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.