Search This Blog

Tuesday, June 29, 2010

Already Exist from SPList item

When you are getting a record through CAML query in search, you can further add some logic on resultset to check case sensitive data. for example in this case your CAML has returned you one item so you are checking that if there is an item returned it means it already exist. so you can do it further like this

//assuming yourCamlReturnedItems is object having returned list item and your manage name to search is in a string //variable sManagerNameToCheck

int iCount=0;
foreach(SPListItem oItem in yourCamlReturnedItems)
{
//case Sensitive match here in code.
if(oItem("ManagerName")==sManagerNameToCheck){iCount=iCount+1;}
}

if(iCount>1)
{
//Manager Name already exist.
}

this will not be slow as you will always have only very few items returned based on name. so just for case sensitivty you can write above line of code further to get the required results after CAML.

No comments:

Post a Comment