| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace Common
- {
- public class EntityBase<T>
- {
- public M format<M>(T t,M m)
- {
- PropertyInfo[] PropertyInfos1 = t.GetType().GetProperties();
- PropertyInfo[] PropertyInfos2 = m.GetType().GetProperties();
- object value;
- foreach (PropertyInfo p2 in PropertyInfos2)
- {
- foreach (PropertyInfo p1 in PropertyInfos1)
- {
- if (p2.Name == "createManNo" || p2.Name == "createManName" || p2.Name == "createTime")
- {
- continue;
- }
- if (p2.Name.ToUpper() == p1.Name.ToUpper())
- {
- value = p1.GetValue(t, null);
- if (value != null)
- {
- p2.SetValue(m, value, null);
- }
- }
- }
- }
- return m;
- }
- }
- }
|