Prefetch Paths

Posts   
 
    
stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 18-Jul-2008 16:05:34   

I am using a prefetch path to bring back NoteTypes for each Note in a collection belonging to a Matter, like this:

prefetch.Add(MatterEntity.PrefetchPathNotes).SubPath = NoteEntity.PrefetchNoteDetails;

public static IPrefetchPath2 PrefetchNoteDetails
        {
            get
            {
                PrefetchPath2 prefetch = new PrefetchPath2(EntityType.NoteEntity);
                prefetch.Add(NoteEntity.PrefetchPathCreatedBy);         
                prefetch.Add(NoteEntity.PrefetchPathNoteType);
                return prefetch;
            }
        }

This works fine, but when I use it, the data that is returned has also pulled back every Note belonging to that NoteType, which is a lot. I only want the NoteType for the notes in the collection, I don't want it to then pull back every note that has that notetype as we are returning the data over WCF and the data is becoming very large.

So for example:

matter.Notes[0].NoteType.Notes is a very large collection, but I don't want it bringing that data back.

Are there any options to control this?

Stephen

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Jul-2008 19:57:21   

If I undertand correctly, this is path your code constructs:

Matter <--(1:n)-- Note --(m:1)--> CreatedBy Note --(m:1)--> NoteType

As you never added a node like NoteType.PrefetchPathNotes, you shouldn't get into that problem. How are you sure the NoteType.Notes collection is fetched?

David Elizondo | LLBLGen Support Team
stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 21-Jul-2008 10:17:57   

I have setup a test method to show the problem.

The screenshot attached, shows the state of the entity when i have fetched it and the code used

As you can see the NoteType contains 56 notentities in a relation I do not want brought back.

Thanks, Stephen

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 21-Jul-2008 10:54:00   

These 56 are the already fetched Notes in the previous PrefetchPath. When a NoteType is assigned to a Note the opposite also happens.

So I bet you won't find any Note in these 56 ones which was does not exist in the Matter.Notes collection.

stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 21-Jul-2008 11:39:00   

Yes, you are correct. Thanks for your help.

Stephen