private SiteInformation GetSiteRequestByCaml(string camlQuery, string filter) { SiteInformation _siteRequest = null; UsingContext(ctx => { Stopwatch _timespan = Stopwatch.StartNew(); CamlQuery _camlQuery = new CamlQuery(); _camlQuery.ViewXml = string.Format(camlQuery, filter); Log.Info("SPSiteRequestManager.GetSiteRequestsByCaml", "Querying SharePoint Request Repository: {0}, Caml Query: {1} Filter: {2}", SiteRequestList.LISTURL, _camlQuery.ViewXml, filter); var _web = ctx.Web; ctx.Load(_web); if (!_web.ListExists(SiteRequestList.TITLE)) { var _message = String.Format("The List {0} does not exist in Site {1}", SiteRequestList.TITLE, _web.Url); Log.Fatal("SPSiteRequestManager.GetSiteRequestsByCaml", _message); throw new DataStoreException(_message); } var _list = ctx.Web.Lists.GetByTitle(SiteRequestList.TITLE); var _listItemCollection = _list.GetItems(_camlQuery); ctx.Load(_listItemCollection, eachItem => eachItem.Include( item => item, item => item[SiteRequestFields.TITLE], item => item[SiteRequestFields.DESCRIPTION_NAME], item => item[SiteRequestFields.TEMPLATE_NAME], item => item[SiteRequestFields.POLICY_NAME], item => item[SiteRequestFields.URL_NAME], item => item[SiteRequestFields.OWNER_NAME], item => item[SiteRequestFields.PROVISIONING_STATUS_NAME], item => item[SiteRequestFields.ADD_ADMINS_NAME], item => item[SiteRequestFields.LCID_NAME], item => item[SiteRequestFields.EXTERNALSHARING_NAME], item => item[SiteRequestFields.PROVISIONING_STATUS_NAME], item => item[SiteRequestFields.ONPREM_REQUEST_NAME], item => item[SiteRequestFields.LCID_NAME], item => item[SiteRequestFields.TIMEZONE_NAME], item => item[SiteRequestFields.BC_NAME], item => item[SiteRequestFields.PROPS_NAME], item => item[SiteRequestFields.STATUSMESSAGE_NAME])); ctx.ExecuteQuery(); _timespan.Stop(); Log.TraceApi("SharePoint", "SPSiteRequestManager.GetSiteRequestsByCaml", _timespan.Elapsed); if (_listItemCollection.Count > 0) { ListItem _item = _listItemCollection.First(); _siteRequest = new SiteInformation() { Title = _item.BaseGet(SiteRequestFields.TITLE), Description = _item.BaseGet(SiteRequestFields.DESCRIPTION_NAME), Template = _item.BaseGet(SiteRequestFields.TEMPLATE_NAME), SitePolicy = _item.BaseGet(SiteRequestFields.POLICY_NAME), Url = _item.BaseGet(SiteRequestFields.URL_NAME), SiteOwner = _item.BaseGetUser(SiteRequestFields.OWNER_NAME), AdditionalAdministrators = _item.BaseGetUsers(SiteRequestFields.ADD_ADMINS_NAME), EnableExternalSharing = _item.BaseGet <bool>(SiteRequestFields.EXTERNALSHARING_NAME), RequestStatus = _item.BaseGet(SiteRequestFields.PROVISIONING_STATUS_NAME), Lcid = _item.BaseGetUint(SiteRequestFields.LCID_NAME), TimeZoneId = _item.BaseGetInt(SiteRequestFields.TIMEZONE_NAME), SharePointOnPremises = _item.BaseGet <bool>(SiteRequestFields.ONPREM_REQUEST_NAME), BusinessCase = _item.BaseGet(SiteRequestFields.BC_NAME), SiteMetadataJson = _item.BaseGet(SiteRequestFields.PROPS_NAME), RequestStatusMessage = _item.BaseGet(SiteRequestFields.STATUSMESSAGE_NAME) }; } }); return(_siteRequest); }