private static ListItemCollection GetSharepointData(string siteUrl, string sharepointList, string sharepointView)
{
ListItemCollection listItems = null;
try
{
Console.WriteLine("Connection to Sharepoint: '{0}'", siteUrl);
ClientContext clientContext = new ClientContext(siteUrl);
Console.WriteLine("Opening Sharepoint list: '{0}'", sharepointList);
List list = clientContext.Web.Lists.GetByTitle(sharepointList);
FieldCollection fields = list.Fields;
clientContext.Load(list);
clientContext.Load(fields, items => items.Include
(item => item.FieldTypeKind,
item => item.Title,
item => item.InternalName));
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
}
catch (Exception ex)
{
Console.WriteLine("EXCEPTION: GetSharepointData Failed to load list {0}", ex.Message);
}
return listItems;
}
No comments:
Post a Comment