Hi,
I've been using the new lambda prefetch syntax but have got stuck when the prefetch path needs to incorporate inherited entities.
I've attached a zip that includes a SQL Server database backup, the lgp file, the generated entity code (adapter model) and a VS 2008 test project to illustrate the problem.
To summarise the model, I have:
- MusicianEntity that has a 1:n relationship with
- MusicianInstrumentEntity that has a n:1 relationship with
- InstrumentEntity
- DrumKitEntity that is a subclassed from InstrumentEntity and has a n:1 relationship with
- ShellMaterialEntity
All nicely contrived, but hopefully fairly clear.
I want to retrieve all musicians, and prefetch everything else as well - including ShellMaterial IF the instrument happens to be a drumkit.
Using the standard PathEdge syntax, it would look something like this:
IPathEdge[] edges = new IPathEdge[]
{
new PathEdge<MusicianInstrumentEntity>(MusicianEntity.PrefetchPathMusicianInstruments,
new PathEdge<InstrumentEntity>(MusicianInstrumentEntity.PrefetchPathInstrument,
new PathEdge<ShellMaterialEntity>(DrumKitEntity.PrefetchPathShellMaterial)))
};
With lambda syntax, I was expecting to be able to do something like:
from m in metadata.Musician.WithPath(mPath => mPath
.Prefetch<MusicianInstrumentEntity>(m => m.MusicianInstruments).SubPath(miPath => miPath
.Prefetch<InstrumentEntity>(mi => mi.Instrument).SubPath(iPath => iPath
.Prefetch<ShellMaterialEntity>(i => i.ShellMaterial))));
But that's not right - because the i being passed is an InstrumentEntity not a DrumKitEntity.
So, how do I construct something like that with the lambda syntax?
Cheers
Ian