Пример #1
0
 //根据id查询实体
 public DomeEntity1 GetInfoBySystemID(int systemId)
 {
     string sql = "select * from Demo_1 where SystemId='" + systemId + "'";
     DomeEntity1 info = new DomeEntity1();
     using (SqlDataReader reader = DBHelper.GetReader(sql))
     {
         info = GetEntityById(reader);
     }
     return info;
 }
Пример #2
0
 /// <summary>
 /// if获取读取器数据
 /// </summary>
 /// <param name="reader">读取器</param>
 /// <returns>数据实体</returns>
 private DomeEntity1 GetEntityById(SqlDataReader reader)
 {
     DomeEntity1 demo = null;
     if (reader.Read())
     {
         demo = new DomeEntity1();
         if (reader["SystemId"] != DBNull.Value) { demo.SystemId = Convert.ToInt32(reader["SystemId"]); }
         if (reader["UserName"] != DBNull.Value) { demo.UserName = Convert.ToString(reader["UserName"]); }
         if (reader["Position"] != DBNull.Value) { demo.Position = Convert.ToString(reader["Position"]); }
         if (reader["Department"] != DBNull.Value) { demo.Department = Convert.ToString(reader["Department"]); }
     }
     return demo;
 }
Пример #3
0
 /// <summary>
 /// 循环获取读取器数据
 /// </summary>
 /// <param name="reader">读取器</param>
 /// <returns>数据集合</returns>
 private List<DomeEntity1> GetEntity(SqlDataReader reader)
 {
     List<DomeEntity1> list = new List<DomeEntity1>();
     DomeEntity1 demo = null;
     while (reader.Read())
     {
         demo = new DomeEntity1();
         if (reader["SystemId"] != DBNull.Value) { demo.SystemId = Convert.ToInt32(reader["SystemId"]); }
         if (reader["UserName"] != DBNull.Value) { demo.UserName = Convert.ToString(reader["UserName"]); }
         if (reader["Position"] != DBNull.Value) { demo.Position = Convert.ToString(reader["Position"]); }
         if (reader["Department"] != DBNull.Value) { demo.Department = Convert.ToString(reader["Department"]); }
         list.Add(demo);
     }
     return list;
 }