This question is locked. New answers and comments are not allowed.
Hi,
For my project, I'm using Entity Framework to manage the access to my database, it works great, and make me the possibility to create complex request with a good maintainability.
I'm using for the first time Asp.Net MVC of telerik, and tried to do the most simple things I could: a table, replacing the default generated table in Asp.Net MVC 3, I only need the page-on-scoll datapaging:
But I directly get this error:
On the
I searched and found this: http://blogs.telerik.com/aspnetmvcteam/posts/10-01-25/resolving-circular-references-when-binding-the-mvc-grid.aspx
But none of the proposal are right for me:
I need ajax databinding due to the pageOnScroll
I need to have navigation properties in both way(one of the good feature of EF I think)
I cannot afford me the time to create ViewModel for each view, I will have something like 80 view, and I've already 50 models.
I sounds like very weird that we do not have any other solutions? In WCF by example, if we have this problem, we can specify our own serializer which supports handling the cyclic references(e.g. http://chabster.blogspot.com/2008/02/wcf-cyclic-references-support.html )
Thank you
For my project, I'm using Entity Framework to manage the access to my database, it works great, and make me the possibility to create complex request with a good maintainability.
I'm using for the first time Asp.Net MVC of telerik, and tried to do the most simple things I could: a table, replacing the default generated table in Asp.Net MVC 3, I only need the page-on-scoll datapaging:
@{
Html.Telerik().Grid(Model)
.Name(
"Grid"
)
.Columns(columns =>
{
columns.Bound(o => o.ContactID);
columns.Bound(o => o.Contact.FirstName);
columns.Bound(o => o.Contact.LastName);
columns.Bound(o => o.BirthDate).Format(
"{0:dd.MM.yyyy}"
);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select(
"_PageOnScroll"
,
"Grid"
))
.Pageable(paging => paging.Style(GridPagerStyles.Status).PageOnScroll(
true
))
.Render();
}
But I directly get this error:
System.InvalidOperationException was unhandled by user code
Message=A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies.Employee_34048F4F6A98297F826C798A27640C7383E95E8EA8282EC8A5F738FA0C77CBC3'.
Source=System.Web.Extensions
StackTrace:
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj)
at Telerik.Web.Mvc.UI.ClientSideObjectWriter.AppendCollection(String name, IEnumerable value) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ClientSideObjectWriter.cs:line 528
at Telerik.Web.Mvc.UI.GridPagingSettings.SerializeTo(String key, IClientSideObjectWriter writer) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Settings\GridPagingSettings.cs:line 131
at Telerik.Web.Mvc.UI.GridClientObjectSerializer`1.Serialize(IClientSideObjectWriter writer) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Serialization\GridClientObjectSerializer.cs:line 52
at Telerik.Web.Mvc.UI.Grid`1.WriteInitializationScript(TextWriter writer) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Grid.cs:line 567
at Telerik.Web.Mvc.UI.ScriptRegistrar.WriteScriptStatements(TextWriter writer) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrar.cs:line 396
at Telerik.Web.Mvc.UI.ScriptRegistrar.Write(TextWriter writer) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrar.cs:line 310
at Telerik.Web.Mvc.UI.ScriptRegistrar.ToHtmlString() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrar.cs:line 317
at Telerik.Web.Mvc.UI.ScriptRegistrarBuilder.ToHtmlString() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ScriptRegistrar\ScriptRegistrarBuilder.cs:line 310
at Telerik.Web.Mvc.{Dynamic}.ScriptRegistrarBuilder.IHtmlString.ToHtmlString()
at System.Web.HttpUtility.HtmlEncode(Object value)
at System.Web.WebPages.WebPageBase.Write(Object value)
at ASP._Page_Views_Shared__Layout_cshtml.Execute() in d:\Workspace\LocalProjects\MvcTestApplication\MvcTestApplication\Views\Shared\_Layout.cshtml:line 29
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.WebPages.WebPageBase.<>c__DisplayClass7.<
RenderPageCore
>b__6(TextWriter writer)
at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)
at System.Web.WebPages.WebPageBase.Write(HelperResult result)
at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body)
at System.Web.WebPages.WebPageBase.PopContext()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<
InvokeActionResultWithFilters
>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
InnerException:
On the
@(Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)))</
body
>
I searched and found this: http://blogs.telerik.com/aspnetmvcteam/posts/10-01-25/resolving-circular-references-when-binding-the-mvc-grid.aspx
But none of the proposal are right for me:
I need ajax databinding due to the pageOnScroll
I need to have navigation properties in both way(one of the good feature of EF I think)
I cannot afford me the time to create ViewModel for each view, I will have something like 80 view, and I've already 50 models.
I sounds like very weird that we do not have any other solutions? In WCF by example, if we have this problem, we can specify our own serializer which supports handling the cyclic references(e.g. http://chabster.blogspot.com/2008/02/wcf-cyclic-references-support.html )
Thank you