Paging and Authorizers

Posts   
 
    
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 17-Nov-2013 22:41:35   

4.0.13.523 SD.LLBLGen.Pro.DQE.SqlServer.dll 4.0.13.0725 SD.LLBLGen.Pro.ORMSupportClasses.dll 4.0.13.406 SD.LLBLGen.Pro.ORMSupportClasses.Web.dll DotNet 4.0 vs2010 project Adapter template SQL Server 2008 R2

Any clues on a way to get paging on a grid to work properly when an Authorizer drops rows?

To get the total rows, I need to iterate through all the entities and update the total count for the grid.

To get the appropriate page, I need to get everything from the first row to some way past the current page full of rows and hope that is enough. If not, I have to go back and do it again with more spare rows in the Take().

ditto for the number of rows on a page.

Both these things negate the performance benefits of just getting a page full with .TakePage(pageNumber, pageSize) unless their is a canny way of optimizing this.

As all my applications are web based, this is causing me to re-assess whether to use authorizers in grids where more than 10 rows or so are normally retuned.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 19-Nov-2013 10:59:26   

An entity which is thrown out by an authorizer is equal to an entity which is a duplicate: it is as if the row was never read. This indeed gives a problem if you fetch x rows to display and one or more are thrown out because of the authorizer.

I don't directly know a solution for this, other than formulating the logic of the authorizer in a predicate expression so you can specify it with the query. I don't know whether this is possible with your authorizer. E.g. you could ask the authorizer to build the predicate expression for you so you keep the logic in one place.

But I don't know whether that's doable in your case, e.g. you might authorize the row against some service...

Frans Bouma | Lead developer LLBLGen Pro
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 19-Nov-2013 12:59:01   

The authorization is against the database using the current user from the HttpContext. I guess your approach is therefore doable, if I actually understood what you mean:-)

How do I ask the authorizer to create the predicate expression? Just call it in the application? Is there an example that is similar I could play with?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 20-Nov-2013 11:28:49   

It's not built in, you have to add the method yourself to your authorizer, but doing so keeps things in the same place (all authorization in one class). So add a static method to the authorizer to produce the predicate for you and pass that to the fetch method. It's not build in because the authorizer works only in memory.

Frans Bouma | Lead developer LLBLGen Pro