Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : General Support : Maintaing lazy loaded child collections

Date Post
8/8/2007 1:33:26 PM

I'm having trouble understanding how to add and remove objects from a lazy loaded child collection. My parent object is Contact and it contains a collection of ContactReason objects.

If I type my collection as IList<ContactReason>, I see that I get an ObjectSet<ContactReason>. An ORMapperException "ObjectSet: Use RemoveKey instead of RemoveAt" is thrown if I attempt to call RemoveAt(0) but there's no public RemoveKey method.

I can call contact.Reasons.Remove(contact.Reasons[0]) on an IList<T>, but not if I type my collection as Collection<T> (I get the same exception as above). If I use Collection<T>, I don't see any way to remove items from the collection. I haven't tried adding items yet.

How should I type my child collections if I'm lazy loading them? What's the best way to add and remove items?

Jamie Ide

BTW, the script for this rich text editor locks up Firefox.

8/9/2007 10:57:26 AM

Hi Jamie:

A lazy-loaded collection is actually an ObjectList.  Both ObjectList and ObjectSet implement IObjectSet, but there are a few differences.  I'm pretty sure one of the differences is that you can use the normal Remove with ObjectList.  Otherwise you'll have to simply delete the object using MarkForDeletion and then requery if you need your list updated.

And sorry about the editor.  It worked in earlier versions of FF, but it does seem that at least some later versions have the lockup.  I probably need to just update the component, but man am I behind.

Thanks, Paul Wilson

8/9/2007 10:57:28 AM

Hi Jamie:

A lazy-loaded collection is actually an ObjectList.  Both ObjectList and ObjectSet implement IObjectSet, but there are a few differences.  I'm pretty sure one of the differences is that you can use the normal Remove with ObjectList.  Otherwise you'll have to simply delete the object using MarkForDeletion and then requery if you need your list updated.

And sorry about the editor.  It worked in earlier versions of FF, but it does seem that at least some later versions have the lockup.  I probably need to just update the component, but man am I behind.

Thanks, Paul Wilson