Refetch an Collection (SelfService)

Posts   
 
    
Bombus
User
Posts: 8
Joined: 15-Apr-2009
# Posted on: 07-Aug-2009 12:56:34   

Hello,

I'm using SelfServicing. In one of my WinForms, I display data in a grid. This Form is used for several Collections, so in my Form, I don't know exactly, what kind of Collection I'm using. I still know, that my DataSource is a ICollection.

Now I have to refetch this Collection. But of course, at this point I don't know, what Collection it is (CustomerCollection, OrderCollection etc.) and also I don't know, what PredicateExpression, PrefetchPath and so on was used for this collection.

In other words: I need a "RefetchCollection", which will use the same PredicateExpression, PrefetchPath ..., which was used at the first call of "GetMulti(.....)".

Do you understand? What could I do?

Is there a way to find out the used PredicateExpression of an Collection? (also PrefetchPath, Rleations and so on).

Thanks for your help,

Alex

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Aug-2009 21:49:36   

Hi Alex,

There is nothing like that. The IEntityCollection is agnostic of the circumstances that produces it (PrefetchPath, Filters, Sorters, etc), and it should be that way. In ASP.Net exist the LLBLGenProDataSource that stays between IEntityCollection and the GUI controls, so it stores the filter, sorter, prefetchPath, etc. In WinForms however, you have to store that variables (IPrefetchPath, IPredicateExpression, etc.) somewhere you can use later to refetch (o refresh) the collection.

David Elizondo | LLBLGen Support Team
Bombus
User
Posts: 8
Joined: 15-Apr-2009
# Posted on: 08-Aug-2009 16:52:57   

Hello daelmo and thank you for your answer.

daelmo wrote:

In WinForms however, you have to store that variables (IPrefetchPath, IPredicateExpression, etc.) somewhere you can use later to refetch (o refresh) the collection.

Is there an event I could use? "BeforeGetMulti" or similar? I didn't find any...

Thank you and best wishes,

Alex

Posts: 1263
Joined: 10-Mar-2006
# Posted on: 09-Aug-2009 00:18:55   

If you were using Linq, you could store the iQueryable object used to generate the query in a custom DTO that includes the collection also....then it could be refreshed easily.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 09-Aug-2009 19:30:49   

Hi Alex,

What exactly you want to achieve? So we could give you the best tips for that. In SelfServicing you could add your own methods to the CollectionClasses to put your own funcionality there. For instance "GetMultiTheNewOrders()" and in there you add the filters, sorters, etc. You also could create a Business Layer that wrap all the GetMulti calls. You also could work on the GUI side, trapping the control's events.

So it is up to you (and your app's scenario).

David Elizondo | LLBLGen Support Team
Bombus
User
Posts: 8
Joined: 15-Apr-2009
# Posted on: 10-Aug-2009 09:17:11   

Hi togehter,

and thanks a lot for your answers.

I still extended my collections via partial classes to get some new properties and so on. So, I think the best way is to write my "own GetMulti"-Method as daelmo wrote. So maybe I will introduce a new Interface which will have a "RefetchCollection"-Method, which will use filter, sorting and so on from last "GetMulti"-Call.

It was my hope there could be a better way with less work :-)

Thank's a lot for your help - now I know my way!

Best wishes,

Alex