This project has moved and is read-only. For the latest updates, please go here.

WhereAny Issue?

Apr 28, 2011 at 7:04 PM

I have a weird thing going on when I use the WhereAny and WhereAll on a list of IDs.

List<int> goalMetrics = new List<int>();

for(int i=1; i<14; i++)

{ goalMetrics.add(i); }// 13 items

var expressions = new List<Expression<Func<SPListItem, bool>>>();

foreach(int metricId in goalMetrics)


expressions.add(x => x["MetricId"] == (DataTypes.LookupId)metricId.ToString());


string camlQuery = Camlex.Query().WhereAny(expressions).ToString().

I am getting the 13 or'ed expressions, but the VALUE in all of the OR'ed expressions end up being 13.

What is that all about??

Apr 28, 2011 at 7:12 PM


That post saved me. It appears the last scoped variable was being used for the whole expression list. So I did

foreach(int metricId in goalMetrics)


string metricIdentifier = metricId.ToString();

expressions.add(x => x["MetricId"] == (DataTypes.LookupId)metricIdentifier);


Apr 28, 2011 at 7:14 PM

yes, I wanted to add a link on this discussion, but you already found it by yourself