Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OData4 $select doesn't contain top navigation property #84

Open
machaofastgmail opened this issue Jul 5, 2023 · 0 comments
Open

OData4 $select doesn't contain top navigation property #84

machaofastgmail opened this issue Jul 5, 2023 · 0 comments

Comments

@machaofastgmail
Copy link

machaofastgmail commented Jul 5, 2023

hi @tschettler

First of all, thanks for your great work on breeze-odata4.

When we migrated our code from odata3 to odata4, we found a small issue. The query below returns different response with odata4.

const query =  new breeze.EntityQuery('ProductDetails') 
.select('Product/Categories')
.expand('Product/Categories') .take(1)

With Odata3, the uri generated will be ProductDetails?$expand=Product/Categories&$select=Product/Categories&$top=1
and the response only has data properties on Category.
image

However with Odata4, the uri generated will be ProductDetails?$expand=Product($select=Categories;$expand=Categories)&$top=1
and the response has extra data properties on ProductDetail and Product , not just on Category.
image

Our workaround is to add top navigation properties to queryOptions.select, like this, and it seems to work fine.

private addSelectOption(entityType: EntityType, queryOptions: QueryOptions, selectClause: SelectClause): void {
    // ......
    queryOptions.select = queryOptions.select || [];   // ~~~~ init select ~~~~~~
    selectClause.propertyPaths.forEach(pp => {
      // ......
      workingOptions.select.push(property);

      if(props.length){    // ~~~~ add top properies if not exsiting~~~~~~
        const rootProperty = props.shift().nameOnServer;
        if (!queryOptions.select.find(p => p === rootProperty)) {
           queryOptions.select.push(rootProperty);
        }       
      }      
    });
  }

image

Would you pls help to address this issue here , thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant