C # retrieve List data from Sharepoint

Source: Internet
Author: User

C # retrieve List data from Sharepoint

C # obtain List data from Sharepoint:

Add reference:

using Microsoft.SharePoint.Client;using System.Data;

Source code:

Public static void getDataFromSPList (string siteURL, string listName) {ClientContext clientContext = new ClientContext (siteURL); Web web = clientContext. web; ListCollection collList = web. lists; clientContext. load (collList); clientContext. executeQuery (); // remote interaction of Sharepoint is executed only after ExecuteQuery. Foreach (Microsoft. sharePoint. client. list list in collList) {Console. writeLine ("Title: {0}", list. title);} // CamlQuery camlQuery = new CamlQuery (); camlQuery. viewXml ="
 "; Microsoft. sharePoint. client. list planlist = collList. getByTitle (listName); ListItemCollection collListItem = planlist. getItems (camlQuery); clientContext. load (collListItem, items => items. include (item => item. id, item => item. displayName, item => item. hasUniqueRoleAssignments); clientContext. executeQuery (); foreach (ListItem olistItem in collListItem) {Console. writeLine ("ID: {0} \ nDisplay name: {1} \ nUnique role assignments: {2}", olistItem. id, olistItem. displayName, olistItem. hasUniqueRoleAssignments);} clientContext. load (planlist); clientContext. executeQuery (); Console. writeLine (planlist. title. toString (); Console. writeLine (planlist. itemCount. toString (); Console. readKey ();}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.