Hello
i am working on a C# web application in which i have to save and restore the state of the application, i am doing this by serialization and deserialization. every thing works fine but the problem is when i deserialize list<object> in which the object has a property from other class , then their reference seems to be broken, only the value is shown but no connection rests
let me show some parts of the code related to the subject:
[DataContract (IsReference = true)]
class course:faculty
{
[DataMember]
private string CourseName;
public string getname
{
get{return CourseName;}
set{CourseName=value;}
}
.
.
.
[DataMember]
private prof professor;
public prof Prof
{
get { return professor; }
set { professor = value; }
}
}
[DataContract(IsReference = true)]
class prof:faculty
{
[DataMember]
private List<course> teaching = new List<course>();
public List<course> Teaching { get { return teaching; } set { teaching = value; } }
}
[DataContract(IsReference = true)]
class level:faculty
{
[DataMember]
private List<course> conflicts = new List<course>();
public List<course> Conflicts { get { return conflicts; } }
}
[DataContract(IsReference = true)]
class faculty:departman
{
.
.
}
[DataContract(IsReference = true)]
class departman
{
.
.
}
i have three list<>
static List<course> Courses = new List<course>();
static List<level> Levels = new List<level>();
static List<prof> Profs = new List<prof>();
i serialize these and save to DB, and then deserialize back to list<> later
now if i access to one the level objects, lets say L1 and change one of its conflicts property from another class, lets say L1.Conflicts.Prof
now the prop value will be change in the levels list but this change never affected to the course list itself on the course.prof property,i think that what is getting from deserialize is the value without the link to the base class
these are all working properly before serialize and deserialize , means if i change course.prof in in an object the value will be assigned to the level.course.prof as well and vise versa
i have used three different methods for serialize and deserialize
both three binary formatter , Protobuf, Json.net (newtonsoft) , all of them acts the same
hope i was clear enough, i am really confused , any help would be appreciated
thanks in advance