This question is locked. New answers and comments are not allowed.
Hey there,
I have a database that I have reverse engineered using OpenAccess. I'm using MVC3 and writing my web site in C#. I have a grid defined as follows...
If I use server binding everything works but when I use ajax binding I get the exception listed below. Based on the stack trace it appears to be a limitation of the JSON serializer built into MVC and I noticed the circular reference changed as I took away navigation properties from my OpenAccess model to eliminate the circular references but doing so greatly limits my future capabilities.
Is there another trick I could use? I contemplated creating a view model but I don't want to reproduce a lot of code.
Server Error in '/' Application.
Exception Details: System.InvalidOperationException: A circular reference was detected while serializing an object of type 'Data.School'.
Source Error:
Stack Trace:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
I have a database that I have reverse engineered using OpenAccess. I'm using MVC3 and writing my web site in C#. I have a grid defined as follows...
@{ Html.Telerik().Grid<Training>() .Name("TrainingGrid") .DataBinding(x => { x.Ajax().Select("GetGridData", "Training"); x.Ajax().Update("UpdateGridData", "Activity"); x.Ajax().Insert("InsertGridData", "Activity"); x.Ajax().Delete("DeleteGridData", "Activity"); } ) .Columns(x => { x.Bound(y => y.TrainingStatus.TrainingStatusName).Title("Status"); x.Bound(y => y.RepCategory.RepCategoryName).Title("REP Category"); x.Bound(y => y.TrainingDate).Format("{0:MM/dd/yyyy}").Title("Training Date"); x.Bound(y => y.Activity); x.Bound(y => y.Purpose); x.Bound(y => y.NumOfHours).Format("{0:#,##0.00}").Title("Hours"); x.Command(y => y.Edit().ButtonType(GridButtonType.Image)); x.Command(y => y.Delete().ButtonType(GridButtonType.Image)); } ) .ToolBar(x => x.Insert().ButtonType(GridButtonType.Image)) .DataKeys(x => x.Add(y => y.TrainingId)) .Pageable(x => { x.PageSize(5); x.Style(GridPagerStyles.Numeric); }) .Sortable(x => x.OrderBy(y => y.Add(z => z.UpdateDate).Descending())) .Render();}If I use server binding everything works but when I use ajax binding I get the exception listed below. Based on the stack trace it appears to be a limitation of the JSON serializer built into MVC and I noticed the circular reference changed as I took away navigation properties from my OpenAccess model to eliminate the circular references but doing so greatly limits my future capabilities.
Is there another trick I could use? I contemplated creating a view model but I don't want to reproduce a lot of code.
Server Error in '/' Application.
A circular reference was detected while serializing an object of type 'Data.School'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.InvalidOperationException: A circular reference was detected while serializing an object of type 'Data.School'.
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
|
Stack Trace:
|
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237