Bug in WhereAny()?

Oct 20, 2013 at 5:52 PM
This is my code:
string[] barcodes = new string[] {
var barCodeIntName="BarCode";
                var expressions = new List<Expression<Func<SPListItem, bool>>>();
                foreach (string bc in barcodes)
                    expressions.Add(srch => ((string)srch[barCodeIntName]) == bc);

                var caml = Camlex.Query().WhereAny(expressions).ToString();
The resulting caml value is the following:
<Where>  <Or>    <Eq>      <FieldRef Name="BarCode" />      <Value Type="Text">20011713</Value>    </Eq>    <Eq>      <FieldRef Name="BarCode" />      <Value Type="Text">20011713</Value>    </Eq>  </Or></Where>
Why it forgets about the 2nd value? Or perhaps I'm doing something wrong? The isues's happening with Camlex 3.1 and 3.5.
Oct 23, 2013 at 9:06 AM
Edited Oct 23, 2013 at 9:07 AM
this is because of how lazy expressions evaluation rules implemented in .Net 3.5 (as far as I remember it was changed in .Net 4) and most popular question. Check the following discussions for solution:
Marked as answer by senglory on 10/23/2013 at 2:17 AM
Oct 23, 2013 at 9:18 AM

It this question is so popular, then I think it would be a good idea to add link to these explanations to the section 9 enlisted on your samples page. Just to help people to get rid of possible confusions.
Oct 23, 2013 at 9:27 AM
Edited Oct 23, 2013 at 9:28 AM
good idea, thank you,
did it.