IT:AD:Breeze.JS:HowTo:Develop Queries
Summary
We use an EntityManager instance to process Queries, in order to retrieve data from the remote service, in order to make entities that are mergeg into the local cache.
Process
The Query is built up fluently using terms similar to what you probably already know from LINQ.
The Predicate takes a small getting used to coming.
function getAllTodos(includeArchived) {
var archivedPredicate = new breeze.Predicate("IsArchived", "==", false);;
var isDonePredicate = new breeze.Predicate("IsDone", "==", true);;
var comboPredicate = archivedPredicate.and(isDonePredicate);
var query = breeze.EntityQuery
.from("Todos")
.where("IsArchived", "==", false);
.where("IsArchived", op.NotEquals, true)
//Or use predicate: .where(archivedPredicate)
//Or use combinined predicates: .where(comboPredicate)
.skip(3*20)
.take(20)
.orderBy("CreatedAt")
.inlineCount() //cute...returns a count of the items on the server.
;
Notice how you built up the where clause before hand, as composite predicates using and and or.
You then send it off and process the async results:
manager.executeQuery(query)
.then(function(data) {
products = data.results; // a page of products beginning with 'C'
resultsCount = products.length; // 0 <= resultsCount < pageSize
inlineCount = data.inlineCount; // count of products beginning with 'C'
});