I am trying to run a CAML query on a BCS list and getting access denied as an error when debugging the code:
SPList CMList = web.Lists[Constants.cmlist];
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='clnum'/></OrderBy>";
SPListItemCollection items = CMList.GetItems(query);
properties.AfterProperties["Title"] = items.Count.ToString(); //error happens on this line
I had a more complicated query before, but I simplified it down to this to try to figure out where the error was coming from. The external list has been limited to 1000 items and I can access it directly with the items displaying correctly in the webpart.
However, when I try to get the count of the items in the query I just ran, I get the error "Access denied by business connectivity services." This doesn't make any sense to me as I can access the list directly with no problem. I have tried wrapping everything in elevated privileges as well to no effect.
Any insight would be appreciated, thanks.
properties
anywhere in your code sample. Also (a long shot) have you set Metadata Store Permission? – Benny Skogberg♦ Nov 1 '13 at 19:50