loading...
Cover image for Using KeywordQuery with CSOM SharePoint Online

Using KeywordQuery with CSOM SharePoint Online

rkosta profile image Ricardo Costa Originally published at blogit.create.pt on ・1 min read
string username = "***********";
string pwd = "*********";
string siteURL = "**********";

ClientContext context = new ClientContext(siteURL);
Web web = context.Web;
SecureString pass = new SecureString();
foreach (char c in pwd.ToCharArray()) pass.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials(username, passWord);
try
{
    KeywordQuery query = new KeywordQuery(context);
    query.QueryText = "ContentType:Factura AND PrecoOWSCURR>10000";

    query.RowLimit = 10;
    query.RowsPerPage = 10;
    SearchExecutor search = new SearchExecutor(context);
    ClientResult<ResultTableCollection> results = search.ExecuteQuery(query);
    context.ExecuteQuery();

    foreach (var resultRow in results.Value[0].ResultRows)
    {
        Console.WriteLine("{0}", resultRow["Title"]);
    }
}
catch (Exception e)
{
    Console.WriteLine(e.ToString());
    Console.ReadKey();
}

The post Using KeywordQuery with CSOM SharePoint Online appeared first on Blog IT.

Posted on by:

rkosta profile

Ricardo Costa

@rkosta

My main focus is on Software Architecture, Enterprise Integration and Azure solutions.

Discussion

markdown guide