This question is locked. New answers and comments are not allowed.
I've got a project that I've created some persistent classes in using OA.
My project has a master page in which I create a Scope for the page using it.
I also have a base class for my UserControls that does the same thing.
I've just written some code that, on a page, starts a transaction, updates the properties of a class (School) on that page and commits the changes to the DB. All good so far.
I've changed the code to update another property in the School instance, which is, in turn is another persistent class (Lesson). If I fetch an instance of Lesson from the DB in the page and update School with it, everything works.
If, however, I use a method in my UserControl - specially written for the task - to return an Lesson instance my attempt commit the changes to School fails with an error...
So, to the question; how can I have multiple UserControls that can return an instance of a persistent class to either a page or another UserControl such that the receiver can update an instance of another class with the received value?
--
Stuart
My project has a master page in which I create a Scope for the page using it.
I also have a base class for my UserControls that does the same thing.
I've just written some code that, on a page, starts a transaction, updates the properties of a class (School) on that page and commits the changes to the DB. All good so far.
I've changed the code to update another property in the School instance, which is, in turn is another persistent class (Lesson). If I fetch an instance of Lesson from the DB in the page and update School with it, everything works.
If, however, I use a method in my UserControl - specially written for the task - to return an Lesson instance my attempt commit the changes to School fails with an error...
Telerik.OpenAccess.Exceptions.InvalidOperationException was unhandled by user code
Message="Object references between two different object scopes are not allowed. The object 'RSD.Model.Lesson' is already managed by 'ObjectScopeImpl 0x31d273f Telerik.OpenAccess.RT.ObjectScope' and was tried to be managed again by 'ObjectScopeImpl 0x24d7226 Telerik.OpenAccess.RT.ObjectScope'."
Source="Telerik.OpenAccess"
CanRetry=true
StackTrace:
at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
at Telerik.OpenAccess.RT.ExceptionWrapper.Throw()
at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x)
at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.commit()
at Telerik.OpenAccess.RT.TransactionImpl.Commit()
at RSD.Website.Controls.LessonDetailsView.dv_ItemUpdating(Object sender, DetailsViewUpdateEventArgs e) in c:\Users\Stuart\Documents\Visual Studio 2008\WebSites\RSD\Controls\School\LessonDetailsView.ascx.cs:line 120
at System.Web.UI.WebControls.DetailsView.OnItemUpdating(DetailsViewUpdateEventArgs e)
at System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation)
at System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
at System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
So, to the question; how can I have multiple UserControls that can return an instance of a persistent class to either a page or another UserControl such that the receiver can update an instance of another class with the received value?
--
Stuart