If i have two objects obj1 and obj2 of same class,how can i copy all properties of obj1 to corresponding properties of obj2 using linq?
I have tried the following and it works,but am interested to know how to do it via linq.
Class1 TargetInstance=new Class1();
Class1 SourceInstance=GetObjectFromSomeWhere();
PropertyInfo[] objAllProps = SourceInstance.GetType().GetProperties();
foreach (var prop in objAllProps)
{
TargetInstance.GetType().GetProperty(prop.Name)
.SetValue(TargetInstance,prop.GetValue(SourceInstance, null), null);
}