Пример #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>
 /// <param name="SQLString">SQL</param>
 /// <param name="PageSize">分页大小</param>
 /// <param name="PageIndex">页号</param>
 /// <param name="cmdParms">参数</param>
 /// <returns></returns>
 public List <T> DBPagEntList <T>(string SQLString, int PageSize, int PageIndex, params MySqlParameter[] cmdParms) where T : new()
 {
     return(EntityConverter.ToList <T>(DBPaging(SQLString, PageSize, PageIndex, cmdParms).Tables[0]));
 }
Пример #3
0
        /// <summary>
        /// 查询并获得实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="SQLString">查询语句</param>
        /// <param name="cmdParms">参数列表</param>
        /// <returns></returns>
        public List <T> QueryEntList <T>(string SQLString, params MySqlParameter[] cmdParms) where T : new()
        {
            DataSet ds = Query(SQLString, cmdParms);

            return(EntityConverter.ToList <T>(ds.Tables[0]));
        }
Пример #4
0
 /// <summary>
 /// 获取实体集合
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="SQLString">查询语句</param>
 /// <param name="cmdParms">参数列表</param>
 /// <returns></returns>
 public List <T> ExeReaEntList <T>(string SQLString, params MySqlParameter[] cmdParms) where T : new()
 {
     return(EntityConverter.ToList <T>(ExecuteReader(SQLString, cmdParms)));
 }
Пример #5
0
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="SQLString">查询语句</param>
 /// <param name="cmdParms">参数列表</param>
 /// <returns></returns>
 public T ExeReaEntity <T>(string SQLString, params OleDbParameter[] cmdParms) where T : new()
 {
     return(EntityConverter.ToEntity <T>(ExecuteReader(SQLString, cmdParms)));
 }