예제 #1
0
        /// <summary>
        /// 查询并获得实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="SQLString">查询语句</param>
        /// <param name="cmdParms">参数列表</param>
        /// <returns></returns>
        public T QueryEntity <T>(string SQLString, params MySqlParameter[] cmdParms) where T : new()
        {
            DataSet ds = Query(SQLString, cmdParms);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(EntityConverter.ToEntity <T>(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(default(T));
            }
        }
예제 #2
0
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="SQLString">查询语句</param>
 /// <param name="cmdParms">参数列表</param>
 /// <returns></returns>
 public T ExeReaEntity <T>(string SQLString, params MySqlParameter[] cmdParms) where T : new()
 {
     return(EntityConverter.ToEntity <T>(ExecuteReader(SQLString, cmdParms)));
 }