How to override FetchAsDataTable method on DataAccessAdapter

Posts   
 
    
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 12-Jul-2017 15:11:32   

Hello,

I know that the method FetchAsDataTable is an override and therefore it can't be overriden. But I'm wondering if there's some other way around ? Somehow to intercept the method call. I have already an application with hundreds of calls to this method.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 12-Jul-2017 16:20:39   

The QuerySpec extension method you mean? It calls into

public virtual void FetchProjection(List<IDataValueProjector> valueProjectors, IGeneralDataProjector projector, QueryParameters parameters)

with a datatable projector. is there a reason you want to intercept this method? There might be other ways to achieve what you want...

Frans Bouma | Lead developer LLBLGen Pro
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 12-Jul-2017 16:31:27   

I need to add a predicate filter to the DynamicQuery object if a certain condition is met.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 13-Jul-2017 09:49:01   

Yes, the OnPrepareForExecutionCallBack is called before the query is executed. But as I said I have already hundreds of queries in my application. I would have to go through all this queries and register the event in each one of them. I don't like this idea :-)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 13-Jul-2017 11:22:55   

Then the only way is to override the method I pointed at above. The FetchAsDataTable will call that method, and you can append your where clause to the QueryParameters object' predicate.

You can test whether it's a datatable fetch or not by checking the first parameter, if it's a DataProjectorToDataTable (https://www.llblgen.com/Documentation/5.2/ReferenceManuals/LLBLGenProRTF/html/5BB1E1E8.htm) class, you know it's a projection to the datatable. Other than that, I don't know an 'easy' way to do it.

Frans Bouma | Lead developer LLBLGen Pro
methodman
User
Posts: 194
Joined: 24-Aug-2009
# Posted on: 13-Jul-2017 13:20:07   

Yeah, this method is looking like the right place. Thank you