Print Page | Close Window

Collection modified error

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=2816
Printed Date: 13-Sep-2025 at 6:28pm


Topic: Collection modified error
Posted By: midnit
Subject: Collection modified error
Date Posted: 07-Jul-2011 at 6:41am
I ran into an error I was not expecting and though I can prevent it I thought maybe it at least shouldn't blow up with this error...
 
I have an entity ContactBa that has a relationship with Contact which has a relationship with Department. When I create a new ContactBa it of course has no Contact which of course has no Department, but if the UI is bound to ContactBa.Contact.Department.Name...I get a collection modified error thrown. I presume its trying to "get" (lazily?) the Contact and Department but of course there is nothing if I justed create the ContactBa entity on the client. Turning off lazy loading did not prevent the error so...maybe its something else. If I remove the UI binding I do not get the error when I add a new ContactBa.
 
Collection was modified; enumeration operation may not execute.    at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at IdeaBlade.Core.EnumerableFns.ForEach[T](IEnumerable`1 items, Action`1 action)
   at IdeaBlade.EntityModel.PendingEntityMap.Update(EntityWrapper pendingWrapper, EntityWrapper realWrapper)
   at IdeaBlade.EntityModel.ScalarEntityReference`1.InformPendingEntityOfRealEntity(EntityWrapper realEntity)
   at IdeaBlade.EntityModel.ScalarEntityReference`1.QueryCallback(EntityQueryOperation op)
   at IdeaBlade.EntityModel.BaseOperation`2.OnCompleted()
   at IdeaBlade.EntityModel.BaseOperation`2.IdeaBlade.EntityModel.IHasAsyncEventArgs.OnCompleted()
   at IdeaBlade.EntityModel.AsyncProcessor`1.<>c__DisplayClass2.<.ctor>b__0(TArgs args)
   at IdeaBlade.EntityModel.AsyncProcessor`1.Signal()
   at IdeaBlade.EntityModel.AsyncProcessor`1.<Execute>b__5(Object x)



Replies:
Posted By: sbelini
Date Posted: 08-Jul-2011 at 10:31am
midnit,
 
Can you upload a sample reproducing the problem?
 
Silvio.


Posted By: sbelini
Date Posted: 08-Jul-2011 at 12:20pm
Hi midnit,
 
Please disregard my previous post. I was able to reproduce it here and will file a bug.
 
Silvio.



Print Page | Close Window