Exemple #1
0
        /// <summary>
        /// async Paging Datas by Database <para />
        /// (need to reference: MicroDBHelperExpansionPack.EntityConversion )
        /// </summary>
        /// <typeparam name="T">Target Type</typeparam>
        /// <param name="pageIndex">Current Index</param>
        /// <param name="pageSize">Size of per Page</param>
        /// <param name="fixedSql">The Sql which in the Front ( ex.  CTE Query begin with the Keyword "WITH" ) </param>
        /// <param name="selectSql">The Sql which begin with Keyword "SELECT" </param>
        /// <param name="paramValues">Parameters</param>
        /// <param name="transaction">transaction</param>
        /// <param name="commandType">Text | StoredProcedure</param>
        public static async Task <PagingResult <T> > PagingAsEntityAsync <T>(int pageIndex, int pageSize,
                                                                             string fixedSql, string selectSql, SqlParameter[] paramValues,
                                                                             MicroDBTransaction transaction, CommandType commandType = CommandType.Text
                                                                             )
            where T : class
        {
            ExecuteAsyncDelegate action = async(m_Sql, m_paramValues, m_commandType) =>
            {
                return(await MicroDBHelper.ExecuteDataTableAsync(m_Sql, m_paramValues, transaction, m_commandType));
            };

            var ret = await AdapterFactory.CreateAdapter(transaction.ConnectionAliasName).DetailPagingAsync(action, pageIndex, pageSize, fixedSql, selectSql, paramValues, commandType);

            return(new PagingResult <T>(EntityConvert.ConvertToList <T>(ret.querydt), pageIndex, pageSize, ret.totalCount));
        }
Exemple #2
0
        /// <summary>
        /// Paging Datas by Database <para />
        /// (need to reference: MicroDBHelperExpansionPack.EntityConversion )
        /// </summary>
        /// <typeparam name="T">Target Type</typeparam>
        /// <param name="pageIndex">Current Index</param>
        /// <param name="pageSize">Size of per Page</param>
        /// <param name="fixedSql">The Sql which in the Front ( ex.  CTE Query begin with the Keyword "WITH" ) </param>
        /// <param name="selectSql">The Sql which begin with Keyword "SELECT" </param>
        /// <param name="paramValues">Parameters</param>
        /// <param name="connectionAliasName">the Alias Name of Connection (if not pass name,it will use the DEFAULT name instead.)</param>
        /// <param name="commandType">Text | StoredProcedure</param>
        public static PagingResult <T> PagingAsEntity <T>(int pageIndex, int pageSize,
                                                          string fixedSql, string selectSql, SqlParameter[] paramValues,
                                                          string connectionAliasName = MicroDBHelper.ALIAS_NAME_DEFAULT, CommandType commandType = CommandType.Text
                                                          )
            where T : class
        {
            ExecuteDelegate action = (m_Sql, m_paramValues, m_commandType) =>
            {
                return(MicroDBHelper.ExecuteDataTable(m_Sql, m_paramValues, connectionAliasName, m_commandType));
            };

            var ret = AdapterFactory.CreateAdapter(connectionAliasName).DetailPaging(action, pageIndex, pageSize, fixedSql, selectSql, paramValues, commandType);

            return(new PagingResult <T>(EntityConvert.ConvertToList <T>(ret.querydt), pageIndex, pageSize, ret.totalCount));
        }