I am doing a POC for a project that I am developing and at the moment I'm in kind of a hard spot.
So, I am receiving a param T which normally is a Model and then I have to check its properties to see which type the props are and then populate them.
To achieve this I am using System.Reflection
which does the job wonderfully!
So far so good, It's working fine.
The problem is when the property in the model is a List
This is the example model that I have:
public List<TestModel2> TestList1 { get; set; }
public string test1 { get; set; }
public string test2 { get; set; }
public string test3 { get; set; }
So, the strings are totally fine, I can receive the Model, see their type and populate their value, the real problem arises when I get TestList1
which I can't seem to get the TestModel2
props and types.
This is a library that I am developing for a project, that's why the param type for the model is T by the way, it's because you can pass different models in which I will populate.
How can I access the Model inside the List<TestModel2>
and check its properties and types with System.Reflection
?
Can you guys give me a hint?
question from:
https://stackoverflow.com/questions/65873459/c-sharp-get-the-model-properties-inside-a-listmodel-and-setvalue-with-system 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…