This is a migrated thread and some comments may be shown as answers.

Problems with New Domain Model and send parameters

3 Answers 173 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 23 Jul 2010, 10:55 PM

Hello
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"
        DataValueField="CodigoColegio">
</telerik:RadComboBox>
<telerik:OpenAccessDataSource ID="OpenAccessDataSourceColegios" runat="server"
        ObjectContextProvider="Prueba.TelerikOrm.AcademicoEntityDiagrams, Prueba.TelerikOrm"
        TypeName="Prueba.TelerikOrm.VColegiosxUsuarios"
        Where="UserName == @UserName">
        <whereparameters>
            <asp:Parameter DefaultValue="0" Name="UserName" />
        </whereparameters>
</telerik:OpenAccessDataSource>

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





3 Answers, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 26 Jul 2010, 03:01 PM
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
0
Brandon
Top achievements
Rank 1
answered on 02 Oct 2011, 07:29 PM
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?
0
Damyan Bogoev
Telerik team
answered on 03 Oct 2011, 02:44 PM
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.

Greetings,
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 >>

Tags
General Discussions
Asked by
Alex
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Brandon
Top achievements
Rank 1
Share this question
or