tips on handling OnCanLoadEntity ThrowAway

Posts   
 
    
mdissel
User
Posts: 92
Joined: 16-Sep-2003
# Posted on: 07-Feb-2008 14:58:27   

Support you have a paged resultset and one or more entities are not added to the collection because OnCanLoadEntity results in a "ThrowAway".. The number of items in the collection is smaller then the pagesize, maybe even 0 (if all records are denied).

Anyone handled this case and what is the optimal solution to always fill the collection with the correct pagesize.. Loading the next pages until you reach the page size in the first collection seems a solution, but not optimal.. ideally you want this deny loading handled in the database with some clever sql.. (see http://www.ayende.com/Blog/archive/2007/11/17/A-vision-of-enterprise-platform-Security-Infrastructure.aspx)

Thanks

Marco

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 07-Feb-2008 15:21:01   

Well if the authorization check was made against values in the database, then you might include this in your GetDBCount() as a filter to only return the total number of entities qualified to be seen by the user, which you should use to count the number of pages needed. Then again you may use the same filter in the fetch method.

But if the check was on some system parameter not in the database, then you might fetch a collection just to determine the authorized PKs of the entities to fetched in a second fetch. (And you might execlude most the fields in your first guiding fetch).

Then you should use the list of PKs accessible to the user in your other paging fetches. Also using this technique you wount need to call GetDBCount() to know the total number of items as you can use the Count of the first fetched guiding Collection.