EntityBase.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Common
  8. {
  9. public class EntityBase<T>
  10. {
  11. public M format<M>(T t,M m)
  12. {
  13. PropertyInfo[] PropertyInfos1 = t.GetType().GetProperties();
  14. PropertyInfo[] PropertyInfos2 = m.GetType().GetProperties();
  15. object value;
  16. foreach (PropertyInfo p2 in PropertyInfos2)
  17. {
  18. foreach (PropertyInfo p1 in PropertyInfos1)
  19. {
  20. if (p2.Name == "createManNo" || p2.Name == "createManName")
  21. {
  22. continue;
  23. }
  24. if (p2.Name.ToUpper() == p1.Name.ToUpper())
  25. {
  26. value = p1.GetValue(t, null);
  27. if (value != null)
  28. {
  29. p2.SetValue(m, value, null);
  30. }
  31. }
  32. }
  33. }
  34. return m;
  35. }
  36. }
  37. }