Datenobjekt verdoppeln c# linq

https://forums.asp.net/t/2141194.aspx?How+to+copy+all+properties+of+an+object+to+another+in+LINQ

 

Kati Ais Kati Ais

Member

17 Points

60 Posts

Re: How to copy all properties of an object to another in LINQ

May 24, 2018 09:21 AM|LINK

Hi,

Follow this example, it may help:

   public class A 
    {
        public string id{ get; set; }
        //Other 24 attributes that you have
    }
 using System.Reflection;
A obj1 = new A();
        A obj2 = new A();

        obj1.id = "aaa";

        var propInfo = obj1.GetType().GetProperties();
        foreach (var item in propInfo)
        {
            obj2.GetType().GetProperty(item.Name).SetValue(obj2, item.GetValue(obj1, null), null);
        }