Пример #1
0
        /// <summary>
        /// 异步查询列表
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connection"></param>
        /// <param name="param"></param>
        /// <param name="predicate"></param>
        /// <param name="keySelector"></param>
        /// <param name="topNumber"></param>
        /// <param name="orderByTypes"></param>
        /// <param name="transaction"></param>
        /// <param name="commandTimeout"></param>
        /// <returns></returns>
        public static Task <IEnumerable <TEntity> > SelectAsync <TEntity>(this IDbConnection connection, object param,
                                                                          Expression <Func <TEntity, bool> > predicate      = null, Expression <Func <TEntity, object> > keySelector = null, int topNumber = 0,
                                                                          Dictionary <string, OrderByTypeEnum> orderByTypes = null,
                                                                          IDbTransaction transaction = null, int?commandTimeout = null)
            where TEntity : BaseEntity
        {
            ISqlAdapter adapter = GetSqlAdapter(connection);

            var sql = adapter.GetSelect(predicate, keySelector, topNumber, orderByTypes);

            if (param == null)
            {
                param = adapter.ParamValues;
            }

            var result = connection.QueryAsyncExt <TEntity>(sql, param, transaction, commandTimeout);

            return(result);
        }