Мне нужна помощь, чтобы получить значение поиска в моем коде c #
с использованием Microsoft.SharePoint.Client;
public static ListItemCollection GetData(string SharePointSiteURL, string
Table, string Query)
{
ClientContext Connection = new ClientContext(SharePointSiteURL);
Connection.Credentials =
System.Net.CredentialCache.DefaultNetworkCredentials;
Connection.RequestTimeout = 3000000;
CamlQuery QueryObject = new CamlQuery();
QueryObject.ViewXml = Query;
Web Web = Connection.Web;
List List = Web.Lists.GetByTitle(Table);
ListItemCollection ListItemCollection = List.GetItems(QueryObject);
Connection.Load(ListItemCollection);
Connection.ExecuteQuery();
return ListItemCollection;
}
string SharePointSiteURL = "SiteURLHidden"
string Table = "Config - Clients";
string Query = @"<View><Query><Where><IsNotNull><FieldRef Name = 'Title'/></IsNotNull></Where></Query><RowLimit>10000</RowLimit></View>";
ListItemCollection listItemCollection = GetData(SharePointSiteURL, Table, Query);
BindableCollection<ClientModel> _allClients = new BindableCollection<ClientModel>();
foreach (ListItem listItem in listItemCollection)
{
_allClients.Add(new ClientModel
{
Client = listItem["Title"].ToString(), //This works fine because its just a string.
PrimaryMethod = (listItem["PrimaryMethod"] as FieldLookupValue).LookupValue //this doesn't as it throws null value exceptions and also this is a multi value lookup field and i have no idea how to handle this in c# code. say i want each value in this as a Collection as well.
}
}
Так что просто вытащить строку из полей поиска с несколькими значениями и вернуть как коллекцию, а не как ошибку, если ноль. Я не могу найти информацию о том, как это сделать где-либо, и я знаю, что он работает так же, как и тот же код в PowerShell, но он работает, так как PowerShell не заботится о типах haha