GROUP BY / Case Insensitivity extension for Asp.Net Web API ODATA?
Asked Answered
T

2

5

Couldn't find a group by references in ODATA V4 documentation. When we pass the group by query in URL it just returns the key, not the actual grouped results.

Any references for using Group by in Asp.Net ODATA, on extensibility points of ODATA Web API. We're in need to take full command over how ODATA query is parsed & transformed into LILNQ to entities query.

I am talking on the line of intercepting ODATA queries and performing manual customization e.g. LINQ to Entities

I am trying to achieve a similar extension for Case Sensitivity. OData Case In-Sensitive filtering in Web API?

Totalizator answered 20/9, 2017 at 10:38 Comment(1)
Maybe you can provide more details of what you expect and what goes wrong, because as far as I know - asp.net odata suppots groupby (and by the way groupby is defined in this spec: docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/…).Cologne
A
0

Try to approach it from SQL perspective:

  1. by grouping you are able to get the keys, exactly, and some aggregate values
  2. by using original filter you used for group and extending it with group keys (original filter and group keys matches) you actually load the data for the given group.

This is how our grouping grid works in angular telerik kendo (they have a nice toOdataString impl. which I also extended: https://github.com/telerik/kendo-angular/issues/2102).

This approach ensures a fixed given amount of groups in the grid (total group or 1st level group).

PRO: you see all the groups (or at least N of them)

CONS: if you unfold a group you might end up with too many items; needs lot of extra code and additional calls with special odata queries;

See: http://www.reflection.sk/#portfolios, check screenshot: Universal Plans Services (UPS) Software Bundle (.NET & Angular with KendoUI)

If you take it from UI perspective:

Then the grouping is nothing more than a list of data with priority sort over the grouped field. This is the default kendo grouping grid aproach. So they just sort the data, get a page-size of it then the grouping UX items are added (virtual items in the grid).

This approach ensures that you got a fixed items in the grid, but when you collapse all items, you might have just 1 or even pageSize count of groups (depending if/how many items are in each of the groups). See it here: https://www.telerik.com/kendo-angular-ui/components/grid/grouping/ - actually you'd need paging to be turned off to see the difference.

With items up to a fixed count this approach is the fastest. Just one call per page, but the count of groups is not know in advance (if you collapse them, it might be just 1 or even N where N is pagesize).

Aniline answered 20/12, 2019 at 20:39 Comment(0)
A
0

Regarding case sensitivity:

  1. when filtering wrapping column name and entered value into tolower() helps:
  2. but it's up to the DB settings how case sensitivity is handled by def.

Also a note: with grouping I was not able to do something like $groupby(tolower(columnname)) with odata, so...

Aniline answered 20/12, 2019 at 20:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.