标签:param ati ret var break val nbsp returns foreach
#region 更新实体模型 /// <summary> /// 更新实体模型 /// </summary> /// <typeparam name="T">源实体类型</typeparam> /// <typeparam name="S">最终合并后返回的实体类型</typeparam> /// <param name="tModel">源数据实体</param> /// <param name="outModel">最终合并后返回的实体</param> /// <returns>最终实体</returns> public static S EntityMerge<T, S>(T tModel, S outModel) { Type type = tModel.GetType(); Type outType = outModel.GetType(); var properties = type.GetProperties(); var outProperties = outType.GetProperties(); foreach (var property in properties) { foreach (var item in outProperties) { if (property.Name == item.Name) { var value = property.GetValue(tModel); item.SetValue(outModel, value, null); break; } } } return outModel; } #endregion
标签:param ati ret var break val nbsp returns foreach
原文地址:https://www.cnblogs.com/heheblog/p/10929925.html