I am interested if there is any way to dynamically map or add a child's object properties to the parent? For example, I have the following classes:
public class Parent {
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Child> Children { get; set; }
}
public class Child {
public int Id { get; set; }
public string Name { get; set; }
}
And I will need to send from the back-end to the front-end in the following format:
public class Dto {
public int ParentId { get; set; }
public string ParentName { get; set; }
public string Child1Name { get; set; }
public string Child2Name { get; set; }
public string Child3Name { get; set; }
}
keeping in mind that the parent can have a different number of children objects.I need this information in this format because it will be displayed in a grid (see image below). Can something like this be achieved and how?
