I have an interesting issue i can not solve at present. I am new to OA and finding it a nice product to use.
My issue is i have a windows forms app, the form uses a bindingsource control, when the form loads the form is bound to a new instance of the entity
At this point the address has not been added to the unit of work so all " should " be ok. Then if i select an address from a drop down and set the binding source
source.DataSource=(Address)lookup.GetSelectedDataRow(); // gets the selected data row from a dropdown
now making changes to the form is fine and then when i call save changes i get the below exception
Now the initial instance of the datasource was not added into the unit of work so i did not expect it to be managed UNTILL i called unitofwork.Add().
How can avoid this occurring or how can i remove the " initial value " from the ObjectScope?? I even tried creating a detached entity thinking that the scope would not be tracking the entity (even though it was not added into the unit of work) but this did not work as it was a " new " instance and was not tracked.
Is there a way to remove an entity from the object graph?? Or not have the entity managed until it is added to the unit of work.
Cheers and thankyou in advance.
Telerik.OpenAccess.Exceptions.InvalidOperationException: Object references between two different object scopes are not allowed. The object 'FreightMaster.Domain.Address' is already managed by 'ObjectScopeImpl 0x3' and was tried to be managed again by 'ObjectScopeImpl 0x6 OpenAccessRuntime.EnlistableObjectScope'.
at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x, Boolean needsRollback)
at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.makePersistent(Object o)
at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.makePersistent(Object o)
at OpenAccessRuntime.ObjectScope.Add(Object pc)
at Telerik.OpenAccess.OpenAccessContextBase.Add(Object entity)
at FreightMaster.UnitOfWork.Context.AddEntity(Object entity) in c:\Projects\FreightMaster\FreightMaster.Data\DataContext\Context.cs:line 245
at FreightMaster.UI.Freight.ConsignmentNote.SaveChanges() in c:\Projects\FreightMaster\FreightMaster.UI.Freight\Forms\ConsignmentNote.cs:line 207