Ejemplo n.º 1
0
        /// <summary>
        /// 业务实体映射EF实体
        /// </summary>
        /// <typeparam name="T">EF实体类型</typeparam>
        /// <param name="dataObj">业务实体对象</param>
        /// <returns></returns>
        public static T ToEntity <T>(this BaseDataObject dataObj) where T : IBaseModel, new()
        {
            var o = new T();

            AutoMapper.Mapper.DynamicMap(dataObj, o, dataObj.GetType(), typeof(T));
            return(o);
        }
        private static object getFieldValue(BaseDataObject dataObj, string mappingField)
        {
            System.Reflection.PropertyInfo prop = dataObj.GetType().GetProperty(mappingField);
            if (prop == null)
            {
                return(null);
            }
            Object returnValue = prop.GetValue(dataObj, null);

            return(returnValue);
        }