I have a class as follows:
public class DummyReturnDto
{
public Set1ReturnDto Foo { get; set; }
public Set2ReturnDto Bar { get; set; }
public DummyReturnDto()
{
Set1 = new Set1ReturnDto();
Set2 = new Set2ReturnDto();
}
}
where all the properties are guaranteed to have classes as their types and will be unique. I would like to use reflection to set the value for the property given a particular type. So for Set1ReturnDto:
var propertyInfo = obj.GetType().GetProperty(Set1ReturnDto, ??????);
propertyInfo.SetValue(obj, value, null);
and then for Set2ReturnDto
var propertyInfo = obj.GetType().GetProperty(Set2ReturnDto, ??????);
propertyInfo.SetValue(obj, value, null);
EDIT:
This is part of the needed knowledge to implement requirements for Generic approach to dealing with multiple result sets from EF stored procedure
DummyReturnDto?SetProperty(Type t, object o)and use that in your helper class rather than the generic typeT(which removes the need for reflection).DummyReturnDtoshould implement that interface by having a dictionary fromTypetoobject. All the getters do something likeSet1ReturnDto Foo { get { return (Set1ReturnDto)_dict[typeof(Set1ReturnDto)]; } }. That would solve this problem, right?