I am using linq to map two similar objects, but I am having an issue that it does not map subclasses it does not even see them in the GetProperties(). The sub classes are marked as public so I am a little confused why this code is not working... Any ideas or suggestions on using the other method/s. Thanks for your help in advance.
foreach (PropertyInfo pInfo in _WorkRequest.GetType().GetProperties())
{
_WorkRequestV1.GetType().GetProperty(pInfo.Name).SetValue(_WorkRequestV1, pInfo.GetValue(_WorkRequest, null), null);
}
UPDATE
After looking into this I have noticed that when declaring a subclass within a class ex:
public Person myPerson;
GetProperties() does not see Person class but if I add
public Person myPerson {get;set;}
GetProperties() does see myPerson
Lastly if I add
public Person myPerson = new Person()
GetProperties() does not see the person.
How come it required {get;set}?