vendredi 14 mai 2021

Map [name,value] string values to class without reflection

I'm having a huge performance issue about mapping string property names and string property values to classes using reflection.

My issue now:

  public class Person
{
    public string Property1 { get; set; }

    public string Property2 { get; set; }

    public string Property3 { get; set; }

    public string Property4 { get; set; }

    // My class has around 100 properties
    public string Property100 { get; set; }
}

I am mapping a key value pair collection to the class using reflection

[{"Property1": "some value"}, {"Property2": "something else"},{"Property3","Property4","value" }.....{"Property100","val"}]

It got to the point that I am now mapping around 10 000 class instances using reflection and the performance is to say it lightly bad.

Any ideas for eliminating the reflection would be greatly appreciated.





Aucun commentaire:

Enregistrer un commentaire