1
votes

When we query for an entity in Breezejs with its key, the framework is creating an url using the $filter property.

/api/orderCollection?$filter=orderId%20eq%20'0001'

Is it possible to force breeze to use the odata format?

/api/orderCollection(0001)

I have a standard odata service and it doesn't support the first url...

this is my query:

var query = new breeze.EntityQuery().from("OrderCollection");
var pred = breeze.Predicate.create('orderId', '==', orderId);
query = query.where(pred);

kr, Joachim

1

1 Answers

4
votes

Breeze always generates OData queries using the $filter operator because that gives us the most flexibility and consistency as you add Predicate expressions. This is part of the OData spec.

However, if you really need the alternative expression you can actually pass the entire URL as a string to Breeze to execute as a query, i.e.

 var query = "orderCollection(0001)";
 myEntityManager.executeQuery(query).then(function (data) {
   ...
 });

Breeze should still return the same results that this will

var query = new breeze.EntityQuery().from("OrderCollection")
   .where('orderId', '==', orderId);
myEntityManager.executeQuery(query).then(function (data) {
    ...
});