Answers for "sharepoint c# get list item query by lookup"

C#
0

c# sharepoint get list item query

using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointServices.Samples
{
    class RetrieveListItems
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
                "<Value Type='Number'>10</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
            ListItemCollection collListItem = oList.GetItems(camlQuery);

            clientContext.Load(collListItem);

            clientContext.ExecuteQuery();

            foreach (ListItem oListItem in collListItem)
            {
                Console.WriteLine("ID: {0} \nTitle: {1} \nBody: {2}", oListItem.Id, oListItem["Title"], oListItem["Body"]);
            }
        }
    }
}
Posted by: Guest on April-13-2021
0

sharepoint c# get list item query by lookup

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='yourColumn' LookupId='TRUE'/><Value Type='Lookup'>123</Value></Eq></Where></Query></View>";
List listByTitle = clientContext.Web.Lists.GetByTitle("YourListName");
ListItemCollection yourListItem = listByTitle.GetItems(camlQuery);

clientContext.Load(yourListItem);
clientContext.ExecuteQuery();
Posted by: Guest on April-14-2021

Code answers related to "sharepoint c# get list item query by lookup"

C# Answers by Framework

Browse Popular Code Answers by Language