This SharePoint tutorial, we will discuss what is the difference between LoadQuery() and LoadDataQuery() in SharePoint 2010/2013.
The Client Object Model has two load methods: Load() and LoadQuery().
Load() method populates the client object directly with what it gets data from the server i.e. a collection object like ListItemCollection etc. But LoadQuery returns the data as a completely new collection in IEnumerable format.
The Collections that you load using the Load() method are eligible for garbage collection only when the client context variable itself goes out of scope whereas, in these collections go out of scope at the end of IEnumerable list.
The Load() method does an in-place loading of the data returned from the server. All of the data returned from the server is stored and tracked inside of the ClientContext object. The ClientContext tracks the object IDs of the items and properties returned from the server.
The LoadQuery() method returns the results as new objects. These objects are not part of the ClientContext and a result can be easily managed and discarded when not needed anymore.
Example LoadQuery() in SharePoint
var query = from list in clientContext.Web.Lists where list.Hidden != false select list; var result = clientContext.LoadQuery(query); clientContext.ExecuteQuery();
Example Load() in SharePoint
var web = clientContext.get_web(); var lists = web.get_lists(); clientContext.Load(lists, 'Title');
You may like following SharePoint tutorials:
- Failed to create the configuration database error in SharePoint 2013
- SHAREPOINT\System account in SharePoint
- File Plan Report in SharePoint 2013
- Calculate difference between two dates Excluding Weekend and Holiday date in SharePoint 2013
- Change URL of List or document Library using SharePoint Designer 2010
- How to enable item level permission in SharePoint list or document library
- Print multiple InfoPath form views in SharePoint 2013/2016/Online
- InfoPath Replace function in SharePoint 2013
- InfoPath 2103 string-before and string-after function in SharePoint
Here we learned what are the difference between LoadQuery() and LoadDataQuery() in SharePoint 2010.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com
Download SharePoint Online Tutorial PDF FREE!
Get update on Webinars, video tutorials, training courses etc.