Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:20:41+00:00 2026-05-27T12:20:41+00:00

I’m using a library (Telerik) for ASP.NET MVC 3. I’ve a problem with all

  • 0

I’m using a library (Telerik) for ASP.NET MVC 3.

I’ve a problem with all functionnalities which needs to return by AJAX some data:

I’m using EF4 to connect my database, and I’ve(and need) navigation properties in both ways(Imagine, a User which have some Posts and one Post have an User).

The problem is that the library is using the JavaScriptSerializer, which encodes data with JSON.

The error that I get

A circular reference was detected while serializing an object of type ‘System.Data.Entity.DynamicProxies.Employee_34048F4F6A98297F826C798A27640C7383E95E8EA8282EC8A5F738FA0C77CBC3’.”

Exception, which is right, because the parent has reference to its children, and children have reference to its parent.

I’ve already found some workaround, but nothing which fully satisfy me:

  • Use data server binding: cannot, the functionnality has to work in ajax(Its a pager for grid, which loads the next elements when the page has been scrolled to the end)
  • Use an anonymous objects: not flexible, because if I’ve a field in addition in the database, I must add it in all my anonymous object, and in addition, if I need to have a sub-collection which I want, it’s boring to also create objects for all element of this sublist.
  • Use ViewModel: Almost same problem, if I’ve one more field, I must add this fields on all viewModel, and I’ve to create an view model for all my 60 views, with exact same fields than my model, …
  • Use the NonSerializedAttribute : I don’t know how to put in my T4 template which generate my POCO objects, and I’m not sure it will works: sometime the main object is the children, sometimes it’s the parent, the empty relations has to be another one.

I had almost the same problem with WCF, and I created a serialized which knows handling circular reference, can we do the same here? Or is there a way to manage this?

If not, I suppose that the best way is to use “ViewModel”, but is there a way to accelerate those creation? Like a generic object, which takes in the constructor the EF object and remove circular reference? anything else?

Thank you very much

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:20:41+00:00Added an answer on May 27, 2026 at 12:20 pm

    Actually, rather than [NonSerialized], it is [ScriptIgnore] that you would need. I would approach this from one of 2 angles, though:

    1. use RegisterConverters and write a custom converter that specifies all the properties except the parent one (this could probably be automated too, maybe using a bespoke class-level attribute like [SkipSerialize("Parent")] added in a partial class – that is probably over-complicating things, though).

    2. simply: don’t serialize the EF POCO, but instead use a DTO – it sounds like this is what you mean in your ViewModel answer. Personally, I have no issue with having an “entity” (EF/POCO) version of a class and a very similar but different DTO version – their intent is different, and in my mind it doesn’t violate DRY.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.