using System;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using System.Text;
using System.Reflection;
namespace CP.Common
{
///
/// 实体类转换
///
public class ToModel
{
public static R Mapping(T model)
{
R result = Activator.CreateInstance();
foreach (PropertyInfo info in typeof(R).GetProperties())
{
PropertyInfo pro = typeof(T).GetProperty(info.Name);
if (pro != null)
{
try
{
info.SetValue(result, pro.GetValue(model));
}
catch (Exception)
{
}
}
}
return result;
}
}
}