0
votes

Using Breeze 1.3.5

Following the "orders for Chai" example, I tried to form a similar query. However, I found that when the resourceName contains a "?", other OData parameters are not correctly added. For example If I do the following:

var query = new breeze.EntityQuery('Products/?categoryId=1234')
            .top(10);

It sends a request that looks like this:

http://domain/controller/Products/?categoryId=1234?$top=10

?$top should be &$top

Because the '?' is used instead of '&', my context controller gets an obviously invalid categoryId that looks like:

1234?$top=10

Am I doing something wrong or is this just a defect? Any ideas or workarounds would be greatly appreciated! Thanks!

1
Found a work around... sort of. Instead of specifying the categoryId in the resourceName, I used the "withParameters" option to add the categoryId. It now correctly returns the data. However, now I see that when you try to perform the same query from the local cache (using FetchStrategy.FromLocalCache), it returns all products in the cache (not just the ones that have the relationship with the specified categoryId).Nova706

1 Answers

0
votes

For Breeze, the resourceName (the value of the 'from' clause in an EntityQuery), is everything after the DataService.serviceName and before the "?".

As you discovered, you can pass any parameters ( i.e. stuff after the ?) via the EntityQuery.withParameters method. The 'where','top','skip', 'select', 'expand' etc clauses of an EntityQuery are also passed as parameters.

This is all by design and there should not be any urls that cannot be constructed with these rules.

To recap, a breeze query url will look like

{serviceName}/{resourceName}?{parameters - separated by '&'}

where

{serviceName}:  DataService.serviceName
{resourceName}: value of EntityQuery.from clause
{parameters}:   serialized and & delimited value of the rest of the EntityQuery including any withParameter values.