how to write quey ( Sharepoint Client ) to fetch data ,based on where clause

Mohammad Qasim 576 Reputation points
2021-03-12T13:23:12.687+00:00

Greetings

Using Sharepoint online to fetch data on asp.net

Issued, its not fetching data based on query ( attached is snap short for reference )

How can I fetch data based on query ,as we usually do in CAML query .

77118-queryallrecords.png

Thanks

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,567 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Arijit_cloud 1 Reputation point Microsoft Employee
    2021-03-14T06:18:18.91+00:00

    Hi,
    You can try this,
    Enclose Where with View and Query,

    camlQuery.ViewXml ="<View><Query><Where>rest of your query here</Where> </Query></View>"

    0 comments No comments

  2. Jerryzy 10,561 Reputation points
    2021-03-15T01:58:27.757+00:00

    Hi @Mohammad Qasim ,

    Add <View><Query></Query></View> outside the real caml:

                    CamlQuery caml = new CamlQuery();  
                    var id = 1;  
                    caml.ViewXml = "<View><Query><Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>"+id+"</Value></Eq></Where></Query></View>";  
                    ListItemCollection items = list.GetItems(caml);  
                    ctx.Load(items);  
                    ctx.ExecuteQuery();  
    

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Jerryzy 10,561 Reputation points
    2021-03-23T06:15:41.64+00:00

    @Mohammad Qasim ,

    Is there any update ? Did the answer solve the question ?

    Thanks
    Best Regards

    0 comments No comments