I'm querying my Search Server and getting some results... How can i get the SPListItem linked to that object?
I tried with many ways, but every method fails..
Here's my code:
string fullsite = SPContext.Current.Web.Url + "/sites/ReplyCorp";
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite scSite = new SPSite(fullsite)) //Collego impersonificando l'utente
{
using (SPWeb webRoot = scSite.OpenWeb())
{
KeywordQuery keywordQuery = new KeywordQuery(scSite);
keywordQuery.ResultTypes = ResultType.RelevantResults;
keywordQuery.RowLimit = 1;
keywordQuery.QueryText = "contentId:" + updateContentObj.contentId;
ResultTableCollection searchResultTables = keywordQuery.Execute();
ResultTable searchResult = searchResultTables[ResultType.RelevantResults];
searchResult.Read();
SPListItem listItem = null;
string url = searchResult["Path"].ToString();
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
debug += "MY URL" + web.Url + "PPPPP" + url;
listItem = web.GetListItem(url);
}
}
});
debug += listItem.Name;
}
}
});
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate(){});
twice? Just once is enough