Skip to content

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

Open

Description

@hrfarrokh

`
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; }
}

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions