Add Filter to Prefetch Root?

Posts   
 
    
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 16-May-2005 18:01:23   

Hey Frans,

Is it possible to add a filter directly to the root node of a prefetch path?

The reasons I wish to do so are fairly complex, and not easy to articulate. It has to do with the way I have Prefetch Paths, Fetches, and Saves abstracted.

In general, I would like to use the same filter and prefetch for two different operations (save and get). If I have to add the filter separately , I will have to maintain the code in two places--if the filter changes, I have to change it in both spots.

I have ways to work around it, but nothing would be as elegant as being able to add the filter to the root node via prefetch. simple_smile

Thanks,

Phil

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-May-2005 18:14:53   

You do that when fetching. The filter you specify in the FetchEntityCollection call is for filtering on the root node. All nodes you specify in the path, you add with path.Add() and you can specify a filter there.

Frans Bouma | Lead developer LLBLGen Pro
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 16-May-2005 18:30:02   

Otis wrote:

You do that when fetching. The filter you specify in the FetchEntityCollection call is for filtering on the root node. All nodes you specify in the path, you add with path.Add() and you can specify a filter there.

Yep, I know. I was just wondering if there was a way to add filters to the root entity.

I can't really think of a good reason to support this except selfish ones (i.e. the way my own code is structured). stuck_out_tongue_winking_eye

Since the filtering only applies to collections, I guess it doesn't make sense to add a filter to a prefetch root node. Because then what would the filter mean if you were doing a single entity fetch?

I actually did my first prefetch paths with filters last week. Recursively (pre)fetched a whole tree of a self-referencing table with a filter on each layer. Awesome!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 17-May-2005 11:54:17   

psandler wrote:

Otis wrote:

You do that when fetching. The filter you specify in the FetchEntityCollection call is for filtering on the root node. All nodes you specify in the path, you add with path.Add() and you can specify a filter there.

Yep, I know. I was just wondering if there was a way to add filters to the root entity.

I can't really think of a good reason to support this except selfish ones (i.e. the way my own code is structured). stuck_out_tongue_winking_eye

I don't quite follow what it would mean, conceptually simple_smile . Could you give an example to illustrate the usage?

I actually did my first prefetch paths with filters last week. Recursively (pre)fetched a whole tree of a self-referencing table with a filter on each layer. Awesome!

smile

Frans Bouma | Lead developer LLBLGen Pro
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 17-May-2005 16:15:59   

Otis wrote:

I don't quite follow what it would mean, conceptually simple_smile . Could you give an example to illustrate the usage?

Nah. simple_smile I think you're right, and it doesn't make sense.

It's complex to explain where I would need it, and I realize now that it would only be useful in the case of a collection fetch.

My situation is different that most people's, since I need to do collection comparisons before I save, and so I have to fetch the collection before I can decide what needs to be saved. So I have prefetches abstracted that I use for both fetches for viewing and fetches for saving. What I wanted was to ensure was that I was using the same filtering techniques for both.

Anyway, I have other ways of handling it, so all is well. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 17-May-2005 16:52:30   

Ok sunglasses

Frans Bouma | Lead developer LLBLGen Pro