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 8748223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:29:17+00:00 2026-06-13T12:29:17+00:00

I have got a class which has many virtual properties lazy loaded public class

  • 0

I have got a class which has many virtual properties lazy loaded

public class TestPlan
{
    public virtual ICollection<Test> Test { get; set; }
    public virtual Commercial Commercial { get; set; }
    ...
}

and this class has to be serialized later in the program. The thing is, as those properties are virtual I’ve got an error (circular reference) everytime I try to serialize it. Now here is my question:

My boss told me to use what he calls View Object which is the same object but without the unused properties. What do you think of this? Should I set those unused properties to null or something?

Background:

The serialized object is meant to be used in an infragistics grid (a nice array). I’ve already tried using the [ScriptIgnore] attribute on my virtuals but it didn’t worked.

I also tried retrieving my TestPlans as database.TestPlans.AsNoTracking().ToList() but got an error (When an object is returned with a NoTracking merge option, Load can only be called when the EntityCollection or EntityReference does not contain objects.)

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 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-06-13T12:29:18+00:00Added an answer on June 13, 2026 at 12:29 pm

    If your Boss means a DataTransferObject with View Object he seems to be going in the right direction.
    This is sometimes also called a ViewModel object in ASP.
    This is just a plain POCO representing a flattened Version of your Model Objects (some use AutoMapper for the flattening)

    You should not modify your model objects but instead create a new object (possibly flattened) for the purpose of serialization. This object has no behaviour just data and represents the contract for serialization.

    I cannot see a circular reference from your example code, but if you want i may give you an unrelated code example that shows how to resolve circular references by flattening. (Difficult to do without knowing the model)

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

Sidebar

Related Questions

I've got a class with many string arrays. I'd like to have one generic
I've got to classes Product and Store which have many to many relation I
I have a model Journey which has many Users (drivers). I want to be
I have a model app which has many to many association with users. Here
I have got the following class structure, and have plenty of classes like C
I am using a readprocessmemory class and have got it to work for reading
I have got a designing dilema. I have a class named UserAccount that represent
I've got the class object for an enum (I have a Class<? extends Enum>
I've got a simple C class I have implemented, using function pointers in a
i have got <div><a class='link' href='index.php' data-container='target'>Load</a></div> <div class='target'></div> i need to write jquery

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.