Reputation: 413
I have a database with Sessions, Clinicians, and a connector table CliniciansInSessions. I'm trying to add a predicate to search for sessions with a clinician's name. The EntityNames are Sessions_Sessions --> Sessions_CliniciansInSessions --> Sessions_Clinicians.
I'm trying to figure out why this predicate:
var p5 = new breeze.Predicate("Sessions_CliniciansInSessions.Sessions_Clinicians.LastName", "contains", "Pras")
is causing this error:
{
$id: "1",
$type: "System.Web.Http.HttpError, System.Web.Http",
Message: "The query specified in the URI is not valid."
}
Here is the whole function:
var loadSessions = function () {
var p1 = new breeze.Predicate("FormatID", "!=", "11");
var p2 = new breeze.Predicate("Year", "==", "2014");
var p3 = new breeze.Predicate("Approved", "==", "true");
var p4 = new breeze.Predicate("Sessions_Rooms.Room", "contains", "Ballroom")
var p5 = new breeze.Predicate("Sessions_CliniciansInSessions.Sessions_Clinicians.LastName", "contains", "Pras")//<--Problem Predicate: invaild query Uri
//var p5 = new breeze.Predicate("Sessions_Clinicians.LastName", "contains", "Pras") //<--Can't find property Sessions_Sessions error
var predicates = breeze.Predicate.and([p1, p2, p3, p4, p5]);
var query = breeze.EntityQuery.from("Sessions_Sessions")
.where(predicates)
.orderBy('StartTime, Title');
return my.manager.executeQuery(query).then(querySucceeded).fail(queryFailed);
function querySucceeded(data) {
my.vm.sessions(data.results);
};
function queryFailed(error) {
$("#error").append(error.message);
};
};
Here's the entire page:
https://github.com/joshbula/LearningBreeze3/blob/master/LearningBreeze3/index.html
The Session_Rooms predicate seems to work okay, so I'm wondering if there's a multiple-child thing causing problems or something? Everything was working until I added that p5 predicate.
Any help would be greatly appreciated.
Upvotes: 0
Views: 137
Reputation: 17052
As of Breeze 1.4.6, 'any' and 'all' operators are now supported.
Breeze predicates currently only work with scalar properties. In other words, you can filter orders by customer i.e via an order.customer property because there is only one customer for an order, but you can't filter a customer on orders i.e via customer.orders because there may be multiple orders on a customer.
This means that today we can this:
EntityQuery.from("Orders").where("customer.name", "==", "smith");
but we can't do this
EntityQuery.from("Customer").where("orders.freightCost", ">" , 100);
because orders.freightCost is conceptually an array of freight costs.
This is the reason for the UserVoice request to support any and all operators: Support any and all operators.
Once we get this into Breeze, your query predicate would look something like this ( we are still working on the right syntax for this).
EntityQuery.from("Customer").where("orders.any(freightCost)", ">", 100);
or
EntityQuery.from("Customer").where("orders.all(freightCost)", ">", 100);
So please vote for this feature on the UserVoice. We take the community's voice seriously in determining which features to work on next.
Upvotes: 1