Declined
Last Updated: 15 May 2024 12:09 by ADMIN
Kristjan
Created on: 09 May 2024 10:16
Category: UI for Blazor
Type: Feature Request
0
Support ORMs that do not require a separate count request for paging

Currently using Telerik.DataSource.QueryableExtensions.CreateDataSourceResult() results in queryable.Count() + queryable.Skip(...).Take(...). done seperatelly. EF Core specific tests are already present it seems, based on decompiled code, I can see: "if (!sort.Any() && queryable.Provider.IsEntityFrameworkProvider())". 

Request: Add support for other ORM's that are more capable than EF Core. In case of pagination, window-function could be used to save from extra count query. A short sample bellow:

var dbResults = await queryable
	.Select(x => new {
		Item = x,
		TotalCount = Sql.Ext.Count().Over().ToValue()
	})
	.Skip(() => offset)
	.Take(() => limit)
	.ToListAsync();

var count = dbResults.FirstOrDefault()?.TotalCount ?? 0;
var items = dbResults.Select(x => x.Item);

Read more about Window functions: https://statics.teams.cdn.office.net/evergreen-assets/safelinks/1/atp-safelinks.html 

3 comments
ADMIN
Dimo
Posted on: 15 May 2024 12:09

Hello Kristjan,

OK, thanks for the clarification.

I have renamed the feature request to reflect its main purpose. Although it's status is Declined, we may revisit it if a lot of other customers show the same interest.

>> One option may be also that we could inject "pagination implementation" capability into already existing functionality. That would require somewhat modular query composing code that may not be the current state of implementation.

Indeed, this is possible, but usually makes sense in specific scenarios only.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Kristjan
Posted on: 15 May 2024 11:09

Sorry about the teams safelinking, but it's just a link to Linq2Db (https://linq2db.github.io/articles/sql/Window-Functions-%28Analytic-Functions%29.html).

Example docs page by PostgreSQL: https://www.postgresql.org/docs/current/tutorial-window.html

We would really like to use ToDataSourceResult() method on queryable and as we've seen, there already is some code specific to EF Core. Similar identification of queryable provider could be implemented for other ORMs (like Linq2Db) which may support more optimal way of composing queries.

If we would need to forego the ToDataSourceResult() method, we would need to implement (or find ready-made solution like Gridify) the whole query composition ourselves.

One option may be also that we could inject "pagination implementation" capability into already existing functionality. That would require somewhat modular query composing code that may not be the current state of implementation.

ADMIN
Dimo
Posted on: 15 May 2024 08:56

Hi Kristjan,

Normally, we provide integrations with standard .NET tooling and avoid supporting third-party products. Out of curiosity, which is the ORM that you have in mind?

In general, if the EF Core mechanism does not suit you, you can implement custom data operations in the OnRead handler without using ToDataSourceResult(). This is a perfectly valid approach. For example, you can generate the SQL query from the DataSourceRequest, as in this Dapper integration sample.

Here is a feature request to support Window functions in .NET Core.

On a side note, the URL at the end of your message doesn't display anything meaningful and I suspect it is some temporary redirect URL.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!