示例#1
0
        public PagerResultSet <T3> GetModelList <T1, T2, T3>(string sql, object pars, string splitOn, PagerParameter pager, Func <T1, T2, T3> map, string Connection = null)
        {
            extend(Connection);
            DapperSqlHelper dsh      = new DapperSqlHelper();
            string          sqlPager = dsh.GetPager(sql, pager);
            string          sqlCount = dsh.GetCount(sql, pager);

            int                 count = _dbConnection.ExecuteScalar <int>(sqlCount, pars);
            List <T3>           rs    = new List <T3>(_dbConnection.Query <T1, T2, T3>(sqlPager, map, pars, null, false, splitOn));
            PagerResultSet <T3> prs   = new PagerResultSet <T3>(rs, count, pager);

            return(prs);
        }
示例#2
0
        public PagerResultSet <T> GetModelList <T>(string sql, object pars, PagerParameter pager, string Connection = null)
        {
            setBaseSql <T>();
            extend(Connection);
            DapperSqlHelper dsh      = new DapperSqlHelper();
            string          sqlPager = dsh.GetPager(sql, pager);
            string          sqlCount = dsh.GetCount(sql, pager);

            int                count = _dbConnection.ExecuteScalar <int>(sqlCount, pars);
            List <T>           rs    = new List <T>(_dbConnection.Query <T>(sqlPager, pars));
            PagerResultSet <T> prs   = new PagerResultSet <T>(rs, count, pager);

            return(prs);
        }
示例#3
0
        public PagerResultSet <T> GetModelList <T>(string sql, object pars, PagerParameter pager, Func <System.Data.IDataReader, T> Transformation, string Connection = null)
        {
            extend(Connection);
            DapperSqlHelper dsh      = new DapperSqlHelper();
            string          sqlPager = dsh.GetPager(sql, pager);
            string          sqlCount = dsh.GetCount(sql, pager);
            int             count    = _dbConnection.ExecuteScalar <int>(sqlCount, pars);
            var             reader   = _dbConnection.ExecuteReader(sql, pars);
            List <T>        list     = new List <T>();

            while (reader.Read())
            {
                list.Add(Transformation(reader));
            }
            reader.Close();
            PagerResultSet <T> prs = new PagerResultSet <T>(list, count, pager);

            return(prs);
        }