I'm a student so sorry if this is really stupid. I have a model called Person which is IEnumerable. Person holds a large amount of attributes such as height weight, eyecolor etc. I can get the properties of Person using
(from t in typeof(Person).GetProperties() select t.Name)
which results in a list. I need to then insert all the Person objects into a 2d array is there a way with a double for loop I can use the list to access the dbo instead of calling every property as hard code?
I was thinking something like
foreach (var (item, i) in properties.Select((item, i ) => (item, i)))
{
array[0][i] = properties[i];
foreach (var(person, j) in people.Select((person, j)=>(person, j)))
{
//this is the part I'm struggling with
array[j][i] = People.property[i];//???
}
}
Aucun commentaire:
Enregistrer un commentaire