コード例 #1
0
        /// <summary>
        /// 返回DataSet
        /// </summary>
        /// <param name="templateId">模板编号</param>
        /// <param name="isReadOnly">是否在只读库查询</param>
        /// <param name="parameters">查询参数</param>
        /// <returns></returns>
        protected List <T> ExecTemplateList <T>(string templateId, bool isReadOnly, List <SqlParameter> parameters = null) where T : new()
        {
            if (string.IsNullOrWhiteSpace(SqlTemplates[templateId].StatementText))
            {
                throw new ArgumentException("模板不能为空");
            }
            var dt = ExecDataSet(SqlTemplates[templateId].StatementText, isReadOnly, parameters).Tables[0];

            return(ConvertDT2DtoList <T> .ConvertToList(dt));
        }
コード例 #2
0
        /// <summary>
        /// 返回对象列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        protected List <T> ExecList <T>(string sql, bool isReadOnly, List <SqlParameter> parameters = null) where T : new()
        {
            DataTable dt = ExecFirstDataTable(sql, isReadOnly, parameters);

            if (dt.Rows.Count <= 0)
            {
                return(new List <T>());
            }

            return(ConvertDT2DtoList <T> .ConvertToList(dt));
        }