Problems with New Domain Model and send parameters

Thread is closed for posting
4 posts, 0 answers
  1. Alex
    Alex avatar
    10 posts
    Member since:
    Jun 2008

    Posted 23 Jul 2010 Link to this post

    ORM I'm using Telerik Q2 2010, and update my application with the new data model DOMAIN MODEL and with the old system I could do something like this:
    <telerik:RadComboBox ID="RadComboBox1" Runat="server"
            DataSourceID="OpenAccessDataSourceColegios" DataTextField="NombreColegio"
    <telerik:OpenAccessDataSource ID="OpenAccessDataSourceColegios" runat="server"
            ObjectContextProvider="Prueba.TelerikOrm.AcademicoEntityDiagrams, Prueba.TelerikOrm"
            Where="UserName == @UserName">
                <asp:Parameter DefaultValue="0" Name="UserName" />

    and the code behind
    Protected Sub OpenAccessDataSourceColegios_Selecting(ByVal sender As Object, ByVal e As Telerik.OpenAccess.OpenAccessDataSourceSelectingEventArgs) Handles OpenAccessDataSourceColegios.Selecting
            e.DataSource.WhereParameters("UserName").DefaultValue = My.User.Name.ToString()
    End Sub

    and now with the new scheme of data it generates the following error:

    The ObjectScope has already been disposed and it's managed persistent objects can no longer be accessed. The ObjectScope should be disposed at the end of the life cycle of your business logic instance. This can also be done in the Dispose of your ASP page or MVC controller.
    Nombre del objeto: 'Telerik.OpenAccess.RT.EnlistableObjectScope'.

    I do not understand that may be happening, if you have not read either online or aid if the new model definitely is not possible to send parameters by code.

    when they relate one with a radcombobox openaccessdatasource as parameter is the same.

    Thank you for your collaboration and attention

    Alex Alfonso
    Bogota Colombia

  2. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 26 Jul 2010 Link to this post

    Hello Alex,

    The exception message shows that the IObjectScope instance which manages the User object is already disposed and you cannot access its properties. It seems that you have disposed the IObjectScope instance before the call of the OpenAccessDataSourceColegios_Selecting method. To avoid the error you could dispose it within the Page_Unload method.
    I recommend that you take a look at the following KB article: “Best Practices in web development with OpenAccess - Part Two” and the corresponding code library example which demonstrates best practices for management of the IObjectScope.
    Hope that helps. If any other problems arise do not hesitate to contact us again.

    Best wishes,
    Damyan Bogoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Brandon
    Brandon avatar
    20 posts
    Member since:
    Nov 2007

    Posted 02 Oct 2011 Link to this post

    I also ran into this issue while using the OpenAccessDataSource.  The article provided by Damyan does not provide any information on how to work with this control.  I was able to work around the issue by setting StoreOriginalValuesInViewState to false for all OpenAccessDataSource instances.

    Is there a way to tie the OpenAccessDataSource to a specific instance of an IObjectContext, such as the factory mentioned in the article?
  4. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 03 Oct 2011 Link to this post

    Hello Brandon,

    I am glad to see that you managed to resolve the problem on your side.
    I am afraid that you are unable to set the underlying IObjectScope instance of the OpenAccessDataSource.

    Damyan Bogoev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

Back to Top