Hi,

How do I solve, if at all possible, the following.

We would like to use the Prefetch() extension method on 2 lists. The hierachy of the lists is like so:

RootEntity <- CitObjectEntity

RootEntity <- ActivityEntity <- PadActivityEntity

<- = Inherits

CitObjectEntity has a EntitySet<activityentity> ActivityList in which, among other ActivityEntities, the PadActivityEntity is added.

Now I'm trying to do something like this:

var result = ActivityList..Prefetch(p => p.PadStatusMomentList);

Of course the compiler does not swallow this because the ActivityList contains entities of type ActivityEntity which in turn does not have the PadStatusMomentList.

How do I solve this problem?

Regards Paul

asked Feb 28 '13 at 08:14

Paul%20Sinnema's gravatar image

Paul Sinnema
261868896


2 Answers:

Hello Paul,

Our prefetch API operates fully on client side, this means you're not limited to operations support by our LINQ translator hence you could use regular type casting for this task:

var result = citObject.ActivityList
                .AsEnumerable() // This is important to perform Select on client side
                .Select(activity => {
                    var padActivity = activity as PadActivity;
                    if (padActivity != null)
                      padActivity.PadStatusMomentList.Prefetch();
                    return activity;
                });

answered Mar 01 '13 at 02:11

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Hi Denis,

We've already created code that automagically fetches sublists as soon as they are needed. If the Prefetch() results in a roundtrip to the server wouldn't have the same result as our delayed fetch of the sublists?

In other words: Since we already fetch the data on demand are there any gains from using the Prefetch instead?

Regards Paul

answered Mar 01 '13 at 02:29

Paul%20Sinnema's gravatar image

Paul Sinnema
261868896

For this particular scenario I think it would be no difference. When you try to enumerate EntitySet<> instance it internally prefetches all of its items.

(Mar 01 '13 at 02:48) Denis Krjuchkov Denis%20Krjuchkov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×13

Asked: Feb 28 '13 at 08:14

Seen: 1,583 times

Last updated: Mar 01 '13 at 02:48

powered by OSQA