Print Page | Close Window

Lazy Load on Many to Many

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3234
Printed Date: 13-May-2026 at 11:36am


Topic: Lazy Load on Many to Many
Posted By: gregweb
Subject: Lazy Load on Many to Many
Date Posted: 25-Jan-2012 at 2:56pm
uploads/579/SilverlightApplication24.zip - SilverlightApplication24.zip

I have a Page with Two Grids on it. On the left is a Grid of Entities. On the right is a grid which shows items related to the Entities on the left. In other words, Navigational Items.

This is wired up and it works ok.

However, the navigational items is actually a many to many link. So the links show, but it's just an id of the actual Entity that I want to show.

ParentEntity -> LinkingEntity -> actual entity.

The only way I could come up with to Bind all the way down to the actual entity was to add custom properties to the Linking Entity that match the actual entity properties. The linking entity has a navigational property to the actual entity so I can retrieve the actual properties through it.

And this works, sort of. It shows the actual properties, but it requires clicking around in the left grid to get the properties in the right to be lazy loaded. The linking entities are propertly loaded, but not the actual entity. After clicking around, it does trigger the lazy load, but it should just be loaded from the start.

Attached is a project that shows this. It connects to a database which I can make available, but it was too big to post on the forum.

One solution on this that I did find was to do an include so the actual entities are downloaded from the start instead of lazy loaded. But there will be too many of the entities to do this at production time, so we are trying to get lazy loading to work.

Also note that I tested this with both the Telerik grid, as well as the Toolkit grid, and they both product the same result. The result is that the actual entities are not loaded initially. When you click on a different row on the right, a two out of the three actual entities are loaded. Clicking back and forth in the left grid finally results in them all being loaded on the right.

Thanks,
Greg



Replies:
Posted By: sbelini
Date Posted: 26-Jan-2012 at 5:30pm
Hi Greg,
 
Since navigation properties are retrieved asynchronously in Silverlight, you should use the PendingEntityResolved and PendingEntityListResolved events.
 
You can find detailed information about asynchronous navigation properties in the http://drc.ideablade.com/xwiki/bin/view/Documentation/asynchronous-navigation-properties - DevForce Resource Center .
 
I'm also attaching a simple solution (based on yours, but using NorthwindIB) that uses lazy loading to populate the right grid.
uploads/892/T11446.zip - uploads/892/T11446.zip
 
Regards,
   Silvio.


Posted By: gregweb
Date Posted: 27-Jan-2012 at 6:29am
Great, thank you very much.



Print Page | Close Window