SharePoint 2010 LoadQuery Vs Load Methods

In SharePoint 2010 we can speak about a year continuously about the new features and APIs. They have included plenty of things and should be made developer life easy!!!
Here is a nice concept I want to tell to my readers about what is the difference between the load() and loadQuery() methods. The main definition both will use to load the data or objects you want from the SharePoint server. Then where is the difference?

To reduce the confusion, first, we will discuss these in the Managed Client OM [C#].
1. Difference in syntax:
Managed Client object model supports two types of syntax in data retrieval process. One is Query syntax [Linq] and another is Method Syntax.

In Query syntax we are using Linq to create queries. Remember, here we are doing Linq to Objects querying but not Linq to SharePoint Provider. It means all the stuff we are writing is client side coding, we can't make or write queries to Linq to SharePoint provider. So, everything should be Linq to Objects only. LoadQuery() syntax can only be used with the query syntax. I mean if you want to write Linq query and execute against client object model, then we should use LoadQuery(). In other words, LoadQuery method takes an object of type IQueryable as its parameter, and this allows us to write LINQ queries instead of CAML to filter the results. Take the below example.
var query = from list 
in clientContext.Web.Lists
where list.Hidden != false
select list;

var result = clientContext.LoadQuery(query);
clientContext.ExecuteQuery();
In the above example, I have used the Linq query to find all the lists which are not hidden. So, this is a straight Linq query and we should use the LoadQuery() method to execute it and get result.

Method syntax can be used with either Load() or LoadQuery(). We can use Lambda expressions to query the data. We can use the same above example with lambda expressions as below.
clientContext.Load(clientContext.Web, 
website => website.Lists.Include(
list => list.Title).Where(
list => list.Hidden != false));

clientContext.ExecuteQuery();
It also produces the same result as above. But the only difference is syntax.
In the above example, we have used the Include phrase. What's is this? It's main advantage is for the performance and efficiency.

How it is improving performance? Because we are returning only the properties we need, not all from the server belongs to requested object. So, Include phrase will tell the server to return only the properties defined in me. In our example, it only asks for Title, so server returns only Title property and loads into the response. This will increase the performance for sure.

How to use Include in LoadQuery() syntax?
IEnumerable hiddenLists = clientContext.LoadQuery(
listCollection.Include(list => list.Title).Where(list => !list.Hidden));

2. Difference in implementation:
Load method populates the client object directly with what it gets data from the server. But LoadQuery returns the data as a completely new collection. For better understanding, LoadQuery() returns the data in the format of IEnumerable<object>. It means all the collection is of type IEnumerable but not straight object collection. For example, in the above example, we have tried to retrieve all lists from the server which are not hidden. If we use Load() method, it returns the ListCollection type. If we use LoadQuery() it returns the IEnumberable type instead of ListCollection. Because of this, when you use Load() method the data will be garbage collected if and only if the ClientContext object goes out of scope. Whereas LoadQuery() object will be garbage collected if the enumerable object goes out of scope irrespective of the ClientContext object.

Using ECMAScript LoadQuery() Vs Load()
What we have discussed about them in the Managed Client Object Model are same here except the server side concepts like garbage collection etc... We will discuss now on how we can implement them in the ECMAScript.
load():
var web = clientContext.get_web();
var lists = web.get_lists();
clientContext.Load(lists, 'Title');
loadQuery():
var collList = clientContext.get_web().get_lists();
this.lists = clientContext.loadQuery(collList, 'Include(Title)');
For filtering data, we need to write the CAML Queries and pull information from server.

Hope this whole concept is completely about the difference between and loadquery and load. And I believe you better understand it. Please let me know the feedback and questions if you have any. Read More...

Porsche Lumma Design CLR 550 R

Meanwhile, under the front cover Lumma Design started with the already powerful 4.8-liter V8 engine that has a standard power of 400 hp In the case of CLR 500 R, however, an additional compressor, which is Scotch on the power more than 50% compared with that of serial Cayenne GTS. And we are accurate, should specify that a power of 612 hp under the front cover. They are transmitted through the asphalt to huge 23-tsolovi wheels obuti in ultra niskoprofilni tires. In general, looks like wheels are painted in black on the end ... This was the tires.

http://img.worldcarfans.com/2008/11/medium/lumma-design-clr-550-r-porsche-cayenne-facelift_5.jpg
To help the Cayenne hard to cope with additional power, Lumma also installed and sports brake system, which provides more power - a good idea in view of the fact that the rate of 612-they koncheta definitely not negligible, especially in a massive and heavy SUV. The car is otherwise reduced by the sport suspension is set so as to reduce the maximum lashkaneto in turn.

http://www.rpmgo.com/cars/d/37070-2/porsche_cayenne_tuning_lumma05.jpg
Inside the interior is a bit more color, as is available in dvutsvetna color. Furthermore, there is a new sport steering wheel and improved telematics system.



Read More...

aston martin db9 wallpaper


aston martin db9
aston martin db9

aston martin db9 wallpapers
aston martin db9 wallpapers

aston martin db9
aston martin db9

aston martin db9 wallpapers
aston martin db9 wallpapers

aston martin db9
aston martin db9

Read More...

aston martin db9 wallpaper


aston martin db9
aston martin db9

aston martin db9 wallpapers
aston martin db9 wallpapers

aston martin db9
aston martin db9

aston martin db9 wallpapers
aston martin db9 wallpapers

aston martin db9
aston martin db9

Read More...

Porsche Panamera 9ff

Porsche Panamera 9ff

The new sedan to the Porsche - Panamera - is not expected to appear on the market before the first half of next year. And although this model will clearly enjoys great popularity among specialists in tuning, as already has computer graphics will look how a modified version of 9ff. And this is not accidental company - still 9ff created that GT9, which may compete with the Bugatti Veyron, and the 911 Turbo Cabrio with power of 780 hp


http://www.0-60mag.com/online/wp-content/uploads/2009/08/2345035.jpg
German masters, who are specialists in a Porsche, has already confirmed that their next major project will be based on the Panamera. While orders for the car is already adopted, it 9ff insist that the project is in very early stage of development.

And while no official specifications for the package, it can learn some things from computer graphics. At least can understand quite ready to form Panamera. For the first time can be seen glass roof of the Porsche, and the rear window. The same is true for the rear lights and rear runout.



Read More...

Bugatti Veyron Price


Bugatti Veyron Price


Bugatti Veyron Price


Bugatti Veyron Price


Bugatti Veyron Price
Read More...

audi tt
audi tt

audi tt pictures
audi tt pictures

audi tt wallpapers
audi tt wallpapers

audi tt
audi tt

audi tt wallpapers
audi tt wallpapers

Read More...

audi tt
audi tt

audi tt pictures
audi tt pictures

audi tt wallpapers
audi tt wallpapers

audi tt
audi tt

audi tt wallpapers
audi tt wallpapers

Read More...

Nissan Skyline

Nissan Skyline

Nissan Skyline
Nissan Skyline Wallpapers
Nissan Skyline Wallpapers
Nissan Skyline
Nissan Skyline Images
Nissan Skyline Photos
Nissan Skyline Photos
Read More...

2010 Audi A1

2010 Audi A1
2010 Audi A1
2010 Audi A1 Wallpapers
2010 Audi A1 Wallpapers
2010 Audi A1
2010 Audi A1 Photos
2010 Audi A1 Interior
2010 Audi A1 Interior
Read More...

Lancer Evo X

Lancer Evo X
Lancer Evo X
Lancer Evo X
Lancer Evo X Wallpapers
Lancer Evo X Wallpapers
Lancer Evo X Photos
Lancer Evo X Photos
Lancer Evo X Images
Read More...
Related Posts with Thumbnails
GiF Pictures, Images and Photos