I have a model that looks like this:
public class MyType{
public string Id {get;set;}
public string Name{get;set;}
public List<MyType> Children{get;set;}
}
and in my data I have only two levels of data, that is, my objects will look like this:
{
MyType{"1","firstParent",
{
MyType{"2","firstChild",null},
MyType{"3","secondChild",null}}
},
MyType{"4","secondParent",
{
MyType{"5","firstChild",null},
MyType{"6","secondChild",null}}
}
}
How can I request a MyType object with a specific identifier, where can it be a parent or a child?
Only parents are listed below.
collection.FirstOrDefault(c => c.id==id)
source
share