Tony Bao
Tony Bao

Reputation: 922

emitmapper circular reference

emit mapper circular reference issues. I am trying to map AA to A. A has object of B, but B has object of A. This is circular reference issue. I am not sure how Emit mapper can handle this issue.

public class A
{
    public A()
    {
        list = new List<B>();
    }
    List<B> list {get; set;}
}

public class B
{
    public A object {get; set;}
}
public class AA
{
    public AA()
    {
           list= new List<BB>();
    }
    public List<BB> list {get; set;}
}
public class BB
{
    public AA object {get; set;}
}
objectified = new A();
ObjectMapperManager.DefaultInstance.Get Mapper<A, AA>().Map(objectified);

Need to map from A to AA. Now I got the stack overflow error. Any one know how to resolve this issue?

Upvotes: 0

Views: 130

Answers (1)

Tony Bao
Tony Bao

Reputation: 922

The circular reference classes are created by EF power tools. And the generated classes need to be updated to one way parent-reference only class. So the issue is not related to the Emitmapper, the issue is the class design itself.

public class A
{
    public A()
    {
        list = new List<B>();
    }
    List<B> list {get; set;}
}

public class B
{
    //remove the following child-parent relationship.
    //public A object {get; set;}
}

Upvotes: 0

Related Questions