zoukankan      html  css  js  c++  java
  • 将实体转换为Hashtable

    1、将实体转换为Hashtable,用于将实体参数处理为hashtable,方便sql参数传递

     1      /// <summary>
     2         /// 将实体转换为Hashtable
     3         /// </summary>
     4         /// <typeparam name="T">实体类型</typeparam>
     5         /// <param name="obj">实体实例</param>
     6         /// <returns>Hashtable</returns>
     7         public static Hashtable ConvertEntityToHashtable<T>(T obj)
     8         {
     9             Hashtable hst = new Hashtable();
    10             try
    11             {
    12                 Type type = obj.GetType();
    13                 foreach (PropertyInfo pi in type.GetProperties())
    14                 {
    15                     PropertyInfo property = type.GetProperty(pi.Name);
    16                     hst.Add(pi.Name, property.GetValue(obj, null));
    17                 }
    18                 return hst;
    19             }
    20             catch (Exception ex)
    21             {
    22                 System.Console.Out.WriteLine(ex.Message);
    23                 return null;
    24             }
    25         }
  • 相关阅读:
    PyQt5对话框
    PyQt5基础控件
    PyQt5主界面
    PyQt5入门
    ioctl太多虚拟内存不够用
    code principles
    Error: watch ENOSPC
    intelJ
    cas
    C的函数指针的作用,以及其赋值是弱类型的
  • 原文地址:https://www.cnblogs.com/MirZhai/p/10059452.html
Copyright © 2011-2022 走看看