예제 #1
0
 /// <summary>
 ///     将DataRow数据装载到实体对象
 /// </summary>
 /// <param name="dr">DataRow对象</param>
 /// <param name="data">实体对象</param>
 private static void LoadWebApi_ParameterEntity(DataRow dr, WebApi_Parameter data)
 {
     if (dr.Table.Columns.Contains("ParameterId"))
     {
         if (!string.IsNullOrEmpty(dr["ParameterId"].ToString()))
         {
             data.ParameterId = int.Parse(dr["ParameterId"].ToString());
         }
     }
     if (dr.Table.Columns.Contains("BaseInfoId"))
     {
         if (!string.IsNullOrEmpty(dr["BaseInfoId"].ToString()))
         {
             data.BaseInfoId = int.Parse(dr["BaseInfoId"].ToString());
         }
     }
     if (dr.Table.Columns.Contains("ParameterName"))
     {
         if (!string.IsNullOrEmpty(dr["ParameterName"].ToString()))
         {
             data.Name = dr["ParameterName"].ToString();
         }
     }
     if (dr.Table.Columns.Contains("Description"))
     {
         if (!string.IsNullOrEmpty(dr["Description"].ToString()))
         {
             data.Description = dr["Description"].ToString();
         }
     }
     if (dr.Table.Columns.Contains("UpdateTime"))
     {
         if (dr["UpdateTime"] != null)
         {
             data.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
         }
     }
     if (dr.Table.Columns.Contains("CreateTime"))
     {
         if (dr["CreateTime"] != null)
         {
             data.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
         }
     }
     if (dr.Table.Columns.Contains("IsDelete"))
     {
         if (dr["IsDelete"] != null)
         {
             data.IsDelete = Convert.ToBoolean(dr["IsDelete"]);
         }
     }
 }
예제 #2
0
 /// <summary>
 ///     将DataTable中的数据装载到List列表
 /// </summary>
 /// <param name="dt">DataTable</param>
 /// <returns>返回列表对象</returns>
 private static List <WebApi_Parameter> LoadWebApi_ParameterToList(DataTable dt)
 {
     if (dt.Rows.Count > 0)
     {
         List <WebApi_Parameter> list = new List <WebApi_Parameter>();
         //循环遍历数据表中的每一行
         foreach (DataRow dr in dt.Rows)
         {
             WebApi_Parameter model = new WebApi_Parameter();
             LoadWebApi_ParameterEntity(dr, model);
             list.Add(model);
         }
         return(list);
     }
     return(null);
 }