Example #1
0
        /// <summary>
        /// dr转换为Dto实体对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dr"></param>
        /// <returns></returns>
        public static T ToEntity <T>(this DataRow dr) where T : class, new()
        {
            DtoMapping dtoMapping = DtoMappingHelper.GetDtoMapping <T>();

            if (dtoMapping.EntityConvertor == null)
            {
                dtoMapping.EntityConvertor = EntityConvertor.CreateEntityConvertor <T>();   //存入dtoMapping中,缓存起来
            }
            return((T)((EntityConvertorDelegate)dtoMapping.EntityConvertor)(dr));
        }