When I add a list in instances value and return that list its provides always duplicate value. I wanna read data from the database table values. But its first iterations add a single row value, the second time its provides 2nd row value and replaces the 1st list values.
var instance = (T)Activator.CreateInstance(type);
while (reader.Read())
{
type.GetProperties().ToList().ForEach(property =>
{
property.SetValue(instance,reader[property.Name]);
});
list.Add(instance);
}
return list;
Aucun commentaire:
Enregistrer un commentaire