Bracket expressions and partial query generation
This is the main improvement comparing to the version 1.0, where you couldn't create complex queries because of lack of bracket expressions support.
Two new methods were added to the builder chain in order to support that: Any
/** Adds And clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
All(...conditions: IExpression): IExpression;
/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
Any(...conditions: IExpression): IExpression;
You can use these methods in conjunction with CamlBuilder.Expression()
for creating bracket expressions, for example like this:
var camlQuery = new CamlBuilder().Where().Any(
As a side effect, you can now create parts of your query separately via CamlBuilder.Expression()
, and then merge them together at some point later. Also you can use CamlBuilder.Expression()
for defining CAMLQuery attribute in SPServices.
Intellisense significantly improved: now different types of fields have different sets of comparison options. Field usage is made more obvious.
- LookupField element improved. No more misleading "casting" of lookups to the target field types: now lookup fields expose methods Id() and ValueAs<type of field>().
- BooleanField element added for fields of boolean type.
- UrlField element added for fields of type URL.
- DateRangesOverlap element improved. It turns out, you cannot use this element in CSOM, because CSOM ignores QueryOptions element. But you still can use DateRangesOverlap with SPServices.
- UserField element improved.
Migration from version 1.0 to version 2.0
None of old elements were removed, but syntax is now more strict, thus in some cases it is possible that some migration will be necessary. Please, post your problems to discussions, if you will have any.
Also, please keep in mind that some elements were marked as deprecated:
- LookupIdField element marked as deprecated and will be removed in the next major release. Please, use LookupField(...).Id() instead.
- Membership element marked as deprecated and will be removed in the next major release. Functionality of Membership element was replaced with set of methods under UserField element.
Internally, TypeScript unit tests (tsUnit) are now used, helping to make the library much more stable. New tests are added.
CamlBuilder is now available via Nuget.
PM> Install-Package CamlJs
PM> Install-Package camljs.TypeScript.DefinitelyTyped