Print Page | Close Window

First Silverlight Use

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=2668
Printed Date: 25-Apr-2026 at 1:33pm


Topic: First Silverlight Use
Posted By: orcities
Subject: First Silverlight Use
Date Posted: 11-May-2011 at 8:53am
I have developed many WPF and Windows apps. This is my first time really using Ideablade with SL.
 
I have run an async query to recieve and entity. Some of the attached entities return detached or null. Do I have to do an Include with all of my async queries?
So basically lazy loading doesn't seem to work. Should it?



Replies:
Posted By: smi-mark
Date Posted: 11-May-2011 at 9:34am
I usually use an Include but I believe it should IsNullOrPendingEntity and an event PendingEntityResolved should fire when it's lazy loaded.


Posted By: orcities
Date Posted: 11-May-2011 at 9:48am
I guess that makes since. I am just used to it lazy loading. So in order to do lazy loading i have to fire the event to raise the changes?


Posted By: smi-mark
Date Posted: 11-May-2011 at 9:50am
If you are databinding to the list then it should just fill in when it loads. Using an include would be the recommended approach though.


Posted By: kimj
Date Posted: 12-May-2011 at 10:42am
I just wanted to expand on what smi-mark said since this is a confusing topic and often causes problems for people new to Silverlight. 
Lazy loading occurs by default in both Silverlight and non-Silverlight DevForce applications, but in Silverlight that load has to be asynchronous because the data has to be fetched from the server.  You don't need to fire any events, and you don't need to listen for the Pending* events unless you want to.
 
Using "Include" means you're doing "eager" loading, and can often be useful when you need an object graph. 
 
The Tour of DevForce Silverlight has a nice example of lazy vs. eager loading and may be worth a look.  You can find it here (and I highly recommend the entire video series) - http://drc.ideablade.com/xwiki/bin/view/Documentation/tour-devforce-silverlight - http://drc.ideablade.com/xwiki/bin/view/Documentation/tour-devforce-silverlight
 



Print Page | Close Window