Hi, This problem pops around the network for years, I've found no good solution yet. The topic is passing a List of Objects which have circular reference inside them populated by NHibernate (with or without lazy load - some sites sais it can't be done with lazy)
Here is the example:
[DataContract]
class Person
{
[DataMemeber]
string Name
[DateMember]
IList<Child> myChilds;
}
[DataContract]
class Child
{
[DataMemeber]
string Name
[DateMember]
Person Father
}
When I try to get all the Persons in my DB: The server code will be:
ICriteria crit = session.CreateCriteria(typeof(Person)));
IList<Base> queryResult = crit.List<Base>();
I get a good results on the SERVER SIDE- a List of all the person, and inside every person I get an List of all the sons (and inside each son - I get an object of Person which inside has an List of his sons ect....)
Now, Trying to Get this List over WCF faults the channel. (if I remove the Person object from the child - it works fine).
Solutions I've tried and did not solved this issue: adding IsReference=true to [DataContract] - didn't help. Moveing all the mapping to not.Lazyload() - didn't help.
Any Ideas how to solve this without rewriting WCF ?
Thanks, Dani