// Function to get value
public SPListItem GetRKListItemByRefNo(SPWeb objSPWeb, string refNo)
{
SPList objSPInvoiceList = objSPWeb.Lists["RKList"];
string camlQuery = string.Empty;
if (!String.IsNullOrEmpty(refNo))
{
camlQuery = "<View><Query><Where><Eq><FieldRef Name='RefNo' /><Value Type='Text'>" + refNo + "</Value></Eq></Where></Query></View>";
}
SPQuery qryInv = new SPQuery();
qryInv.ViewXml = camlQuery;
SPListItemCollection incAnaCol = objSPInvoiceList.GetItems(qryInv);
return incAnaCol[0];
}
// Calling the function
SPListItem item = GetRKListItemByRefNo(web, itemRefNo);This code snippet will help SharePoint list item by list unique field using CAML Query.
