var sourceProperties = entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
var targetProperties = patent.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
foreach (PropertyInfo item in sourceProperties)
{
if (item.Name == "Id"||item.Name == "LegalUpdateTime")
continue;
if (item.PropertyType.IsValueType ||item.PropertyType.Name.StartsWith("String"))
{
if (item.GetValue(entity)!=null)
{
var firstOrDefault = targetProperties.FirstOrDefault(p => p.Name == item.Name);
if (firstOrDefault != null)
firstOrDefault.SetValue(patent, item.GetValue(entity));
}
}
}