简体   繁体   English

Asp.Net Web API ODATA 的 GROUP BY/不区分大小写扩展?

[英]GROUP BY / Case Insensitivity extension for Asp.Net Web API ODATA?

Couldn't find a group by references in ODATA V4 documentation.无法通过 ODATA V4 文档中的引用找到组。 When we pass the group by query in URL it just returns the key, not the actual grouped results.当我们在 URL 中通过查询传递 group by 时,它只返回键,而不是实际的分组结果。

Any references for using Group by in Asp.Net ODATA, on extensibility points of ODATA Web API.在 Asp.Net ODATA 中使用 Group by 的任何参考,关于 ODATA Web API 的可扩展性点。 We're in need to take full command over how ODATA query is parsed & transformed into LILNQ to entities query.我们需要完全控制 ODATA 查询如何解析并转换为 LILNQ 到实体查询。

I am talking on the line of intercepting ODATA queries and performing manual customization eg LINQ to Entities我正在谈论拦截 ODATA查询和执行手动定制,例如 LINQ to Entities

I am trying to achieve a similar extension for Case Sensitivity.我正在尝试为区分大小写实现类似的扩展。 OData Case In-Sensitive filtering in Web API? Web API 中的 OData 大小写不敏感过滤?

Try to approach it from SQL perspective:尝试从 SQL 的角度来处理它:

  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 ).这就是我们的分组网格在 angular telerik kendo 中的工作方式(他们有一个很好的 toOdataString impl。我也扩展了它: 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) PRO:您会看到所有组(或至少 N 个)

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;需要大量额外的代码和额外的特殊 odata 查询调用;

See: http://www.reflection.sk/#portfolios , check screenshot: Universal Plans Services (UPS) Software Bundle (.NET & Angular with KendoUI)请参阅: http : //www.reflection.sk/#portfolios ,查看截图:Universal Plans Services (UPS) Software Bundle (.NET & Angular with KendoUI)

If you take it from UI perspective:如果你从 UI 的角度来看:

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).所以他们只是对数据进行排序,获取它的页面大小,然后添加分组 UX 项目(网格中的虚拟项目)。

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).这种方法可确保您在网格中获得固定的项目,但是当您折叠所有项目时,您可能只有 1 个甚至 pageSize 的组计数(取决于每个组中是否/有多少项目)。 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.在此处查看: https : //www.telerik.com/kendo-angular-ui/components/grid/grouping/ - 实际上您需要关闭分页才能看到差异。

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).每页只调用一次,但事先不知道组的数量(如果折叠它们,它可能只是 1 甚至 N,其中 N 是页面大小)。

Regarding case sensitivity:关于区分大小写:

  1. when filtering wrapping column name and entered value into tolower() helps:过滤包装列名称并在 tolower() 中输入值时有帮助:
  2. but it's up to the DB settings how case sensitivity is handled by def.但这取决于数据库设置 def 如何处理区分大小写。

Also a note: with grouping I was not able to do something like $groupby(tolower(columnname)) with odata, so...另请注意:通过分组,我无法使用 odata 执行 $groupby(tolower(columnname)) 之类的操作,因此...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM