DataScope and multi parented objects

Posts   
 
    
yowl
User
Posts: 266
Joined: 11-Feb-2008
# Posted on: 06-Apr-2021 01:05:44   

Hi,

With LLBLGen adapter, 5.8.1. If I retrieve the graph

A--with path to -B - with path to- C
   \with path to -D

And C also has a fk to D, where D is the parent. When using the FastSerializer with the DataScope, how should I go about recreating the graph on the client so that I can do D.C ? There's nothing built in to do this I suppose? I'm coming from RiaServices where this happened automatically as part of deserializing on the client.
I can do it manually by knowing on the client what the prefetch was on the server and recreating the missing links based on the keys, but wondered if the DataScope, as it knows about all the retrieved entities, could help?

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Apr-2021 08:10:37   

Hi yowl,

I'm not sure I understand clearly...

  • Could you please show an example of how would you fetch such graph in the DataScope?
  • AFAIK, FastSerialization works on Entities, TypedLists, TypedViews and UnitOfWork2 objects, not DataScope. Would you plan to transfer DataScope over remoting or something like that?
David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Apr-2021 09:10:58   

I think if you add a prefetch path node for D.C in the graph as well and fetch it with a context, the same C instances are referenced by D as are referenced by B. The fast serializer will rebuild this graph when deserializing.

Frans Bouma | Lead developer LLBLGen Pro
yowl
User
Posts: 266
Joined: 11-Feb-2008
# Posted on: 06-Apr-2021 13:56:15   

Hi,

The prefetch would look like this:

(from a in meta.A
                    select a)
                                      .WithPath(ap => ap.Prefetch<BEntity>(aa => aa.B).SubPath(bp => bp.Prefetch(bb => bb.C))
                                      .Prefetch(ap => ap.D)

Yes, I suppose I could prefetch C again from D, although that would mean selecting the C entities twice. But that does make me think that I could do the linking on the server before serialization which would at least be better than doing it on the client as I wouldn't be duplicating the knowledge of the prefetch path to the client.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Apr-2021 16:49:00   

If you can enumerate the C instances to assign them to D's on the server, then sure, that should work out fine. As the FK values are fetched, they won't change by the assignments.

Frans Bouma | Lead developer LLBLGen Pro
yowl
User
Posts: 266
Joined: 11-Feb-2008
# Posted on: 06-Apr-2021 17:03:47   

Got it, thanks.