This project is read-only.
1
Vote

Expression in conjuction with ToCamlQuery produces wrong output

description

Create query:
var orderExp = CamlBuilder.Expression().CounterField(SPListRepo.Fields.ID).NotEqualTo(0).OrderByDesc("ID");
var camlQuery = new CamlBuilder().View().Query().Where().All(orderExp).ToCamlQuery();
console.log(camlQuery.get_viewXml());
outputs:
<View>
    <Query>
        <View>
            <Query>
                <Where>
                    <Neq>
                        <FieldRef Name="ID" />
                        <Value Type="Counter">0</Value>
                    </Neq>
                    <OrderBy>
                        <FieldRef Name="ID" Ascending="False" />
                    </OrderBy>
                </Where>
            </Query>
        </View>
    </Query>
</View>
Issues: double view tag, incorrect placement for OrderBy statement.
If you call ToString() instead of ToCamlQuery() it will generate:
<View>
    <Query>
        <Where>
            <Neq>
                <FieldRef Name="ID" />
                <Value Type="Counter">0</Value>
            </Neq>
            <OrderBy>
                <FieldRef Name="ID" Ascending="False" />
            </OrderBy>
        </Where>
    </Query>
</View>
Issues: incorrect placement for OrderBy statement

comments

omlin wrote Mar 24, 2015 at 6:53 PM

Thanks for reporting! Will try to fix this ASAP.