edandersen / core-admin

Fully automatic admin site CRUD UI generator for ASP.NET Core and .NET 8
Other
561 stars 106 forks source link

if (!Model.Rows.Any() causes re-execution of the select statement against SqlServer Table #84

Closed Dredy closed 1 year ago

Dredy commented 1 year ago

In the partial _Grid.cshtml there is an if statement, that check if there any rows, in order to display an "Empty table message"

https://github.com/edandersen/core-admin/blob/93370854f40bfa1fa94d9d2915ce2c7db4ab4fe6/src/DotNetEd.CoreAdmin/Views/Shared/MvcGrid/_Grid.cshtml#L148

The Model.Rows.Any() causes the re-execution of the query against the database. After commenting the section the database will be called only one time.

I will search a better way to expose the Zero rows message.

edandersen commented 1 year ago

Better to report this to the MvcGrid project. Not going to fork the views from their templates.

If you are worried about hyperoptimisation of queries I highly suggest building a custom admin panel - this is just a quick tool.


From: Dredy @.> Sent: Sunday, April 16, 2023 8:44:34 PM To: edandersen/core-admin @.> Cc: Subscribed @.***> Subject: [edandersen/core-admin] if (!Model.Rows.Any() causes re-execution of the select statement against SqlServer Table (Issue #84)

In the partial _Grid.cshtml there is an if statement, that check the number of rows, in order to display an "Empty table message"

https://github.com/edandersen/core-admin/blob/93370854f40bfa1fa94d9d2915ce2c7db4ab4fe6/src/DotNetEd.CoreAdmin/Views/Shared/MvcGrid/_Grid.cshtml#L148

The Model.Rows.Any() causes the re-execution of the query against the database. After commenting the section the database will be called only one time.

I will search a better way to expose the Zero rows message.

— Reply to this email directly, view it on GitHubhttps://github.com/edandersen/core-admin/issues/84, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAEF6HEP5YU2M3NJRNU22CLXBPLSFANCNFSM6AAAAAAXAB4TMU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Dredy commented 1 year ago

Better to report this to the MvcGrid project. Not going to fork the views from their templates. If you are worried about hyperoptimisation of queries I highly suggest building a custom admin panel - this is just a quick tool.

I know that the View is on the Mvc.Grid source, but Your DLL contains that View. This is just a quick tool, but it can be improved.

btw: Peace and love, it's not necessary to be so rude in your replies.