Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent Child relationship with the same types,Never Ends #40

Open
hrfarrokh opened this issue Jul 31, 2016 · 0 comments
Open

Parent Child relationship with the same types,Never Ends #40

hrfarrokh opened this issue Jul 31, 2016 · 0 comments

Comments

@hrfarrokh
Copy link

`
public class SlapperParent
{
static void Main()
{

        Dictionary<string, object> dic = new Dictionary<string, object>();

        dic.Add("ID", 10);
        dic.Add("Name", "Object Name");

        dic.Add("Parent_ID", 20);
        dic.Add("Parent_Name", "Parent Name");


        var result = Slapper.AutoMapper.Map<ClassA>(dic); ;

        WriteLineRecursive(result);
        Console.WriteLine(result);
        Console.ReadLine();
    }

    private static void WriteLineRecursive(ClassA obj)
    {
        if (obj == null)
        {
            Console.WriteLine("Object Is NULL. Return; ");
            return;
        }

        //Console.WriteLine("Object ID : " + obj.ID);
        Console.WriteLine("Object Name : " + obj.Name);

        if (obj.Parent == null)
        {
            Console.WriteLine("Parent Is NULL. Return; ");
            return;
        }

        WriteLineRecursive(obj.Parent);

        //Console.WriteLine("Parent ID : " + obj.Parent.ID);
        //Console.WriteLine("Parent Name : " + obj.Parent.Name);

    }
}


public class ClassA
{
    public int? ID { get; set; }
    public string Name { get; set; }
    public ClassA Parent { get; set; }
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant