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