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

Support to query number of collection property using /$count #3174

Open
xuzhg opened this issue Feb 3, 2025 · 1 comment · May be fixed by #3175
Open

Support to query number of collection property using /$count #3174

xuzhg opened this issue Feb 3, 2025 · 1 comment · May be fixed by #3175
Assignees
Labels

Comments

@xuzhg
Copy link
Member

xuzhg commented Feb 3, 2025

1. /$count can append to collection navigation property within $expand

  • ~/customers(1)?$expand=Orders/$count

The payload could be:

{
   "@odata.context": ....,
   "Id":1,
   ....
  "[email protected]": 5
}

The above scenario is valid, then it should be valid to do the same thing to non-navigation property.
So, Need to support:

2. /$count can append to primitive/complex collection property within $select

  • ~/customers(1)?$select=Emails/$count

The payload could be:

{
   "@odata.context": ....,
   "[email protected]": 5
}

Be noted, from OData ABNF (Part):

select         = ( "$select" / "select" ) EQ selectItem *( COMMA selectItem )
selectItem     = STAR
               / allOperationsInSchema 
               / [ ( qualifiedEntityTypeName / qualifiedComplexTypeName ) "/" ] 
                 ( selectProperty
                 / qualifiedActionName  
                 / qualifiedFunctionName  
                 )
selectProperty = primitiveProperty  
               / primitiveColProperty [ OPEN selectOptionPC *( SEMI selectOptionPC ) CLOSE ]
               / navigationProperty
               / selectPath [ OPEN selectOption *( SEMI selectOption ) CLOSE
                            / "/" selectProperty 
                            ]


propertyPath = entityColNavigationProperty [ collectionNavigation ]
             / entityNavigationProperty    [ singleNavigation ]
             / complexColProperty          [ complexColPath ]
             / complexProperty             [ complexPath ]
             / primitiveColProperty        [ primitiveColPath ]
             / primitiveProperty           [ primitivePath ]
             / streamProperty              [ boundOperation ]

primitiveColPath = count / boundOperation / ordinalIndex
@xuzhg
Copy link
Member Author

xuzhg commented Feb 3, 2025

However, from OData ABNF, we can see the difference between $expand and $select

$expand $select
Image Image

For $expand, it explicitly mentions "/$count" after the expand path, but, there's no such "$count" after the select path?

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

Successfully merging a pull request may close this issue.

1 participant