vendredi 22 octobre 2021

How to get all Guid properties and their values with the name "Id" from class?

I have a class which has nested objects. I wanna get all the Guid properties and their values with the name "Id". This is simple version of my classes:

public class Main
{
    public Guid Id { get; set; }

    public ICollection<Child> Children { get; set; }
}

public class Child
{
    public Guid Id { get; set; }
    public ICollection<GrandChild> GrandChildren { get; set; }
}

public class GrandChild
{
    public Guid Id { get; set; }
}

I am gonna have Main class object and wanna retrieve all Guid properties with their values for all nested and etc. for further logic. Any suggestions?





Aucun commentaire:

Enregistrer un commentaire