DEV Community 👩‍💻👨‍💻

Cover image for Using KeywordQuery with CSOM SharePoint Online
Ricardo Costa
Ricardo Costa

Posted on • Originally published at on

Using KeywordQuery with CSOM SharePoint Online

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);
    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);

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

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

Top comments (0)

Hey 😍

Want to help the DEV Community feel more like a community?

Head over to the Welcome Thread and greet some new community members!

It only takes a minute of your time, and goes a long way!