I've googled that it can be in case when query is not well-formed. But I'm verifying it for several hours and didn't find any mistake. Problem is common: query doesn't filters and returns all data.

I have no idea what is wrong, because I checked this query in Stramit CAML viewer and it worked fine.

        private static SPListItemCollection GetItemsForThisUserAndEvent(SPList list)
            const string queryMask = 
            <FieldRef Name='{0}' LookupId='TRUE' />
            <Value Type='Lookup'>{1}</Value>
            <FieldRef Name='{2}' LookupId='TRUE' />
            <Value Type='User'>{3}</Value>

            var query = string.Format(queryMask, MemberListFieldLookupEventName, SPContext.Current.ListItem.ID,
                                                 MemberListFieldLogin, SPContext.Current.Web.CurrentUser.ID);
            return list.GetItems(query);

1 Answer 1


Query in your case is a string, which means that you are using the SPList.GetItems(String[]) overload.

That method accept a list of fields to load, not a query. You should be using one of the overloads that accepts an actual SPQuery object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.