IN operator allows us to specify multiple values in where clause.deactivation. Generally we will use IN operator in SQL.
In CAML query also we can use IN operator. In my recent project i have a requirement to get the announcements present in the announcements list. Here the condition is only i need to get the id with 1,2. So we can use IN query in this scenario. Because we need to specify multiple values in where clause.
Let us see how to use the same both in .Net CSOM and Server object model.
code snippet for CSOM:--
Let us see how to use the same both in .Net CSOM and Server object model.
code snippet for CSOM:--
ClientContext clientContext = new ClientContext("your site"); Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Announcements"); clientContext.Load(spList); clientContext.ExecuteQuery(); if (spList != null && spList.ItemCount > 0) { Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @"Code snippet for Server object model"; ListItemCollection listItems = spList.GetItems(camlQuery); clientContext.Load(listItems); clientContext.ExecuteQuery(); } 1 2
SPList spList = spWeb.Lists.TryGetList("Announcements"); if (spList != null) { SPQuery qry = new SPQuery(); qry.Query = @""; qry.ViewFields = @" 1 2 "; SPListItemCollection listItems = spList.GetItems(qry); }
Can you provide solution?
ReplyDeletequeryBuilder.Append("");
ReplyDeletequeryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("121000");
queryBuilder.Append("129000");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
Not working this in my case
queryBuilder.Append("");
ReplyDeletequeryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("121000");
queryBuilder.Append("129000");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");
queryBuilder.Append("");