Ejemplo n.º 1
0
        /// <summary>
        /// 使用指定类型的默认构造函数来创建该类型的实例然后根据传入的DataRow 给这个实例对象赋值
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        private static T GetDataRow(DataRow row)
        {
            //T t = new T();
            //T t = Activator.CreateInstance(type) as T;
            T t = Activator.CreateInstance <T>();

            string[] names = GetModifyNames(info);
            for (int i = 0; i < names.Length; i++)
            {
                PropertyInfo proInfo = type.GetProperty(names[i]);
                proInfo.SetValue(t, UtilHelper.FromDbValue(row[(names[i])]), null);
            }
            return(t);
        }