/// <summary> /// Query /// 根据条件查询。 /// </summary> /// <typeparam name="TEntity">类型参数</typeparam> /// <param name="connection">DbConnection</param> /// <param name="predicate">条件表达式目录树</param> /// <returns>TEntity 集合</returns> public static IEnumerable <TEntity> Query <TEntity>(this IDbConnection connection, Expression <Func <TEntity, bool> > predicate) { try { if (SqlCheck.Check <TEntity>(predicate)) { DynamicParameters parameters; var querySQL = BuildSelectSql(predicate, out parameters); return(SqlMapper.Query <TEntity>(connection, querySQL, parameters)); } else { return(DommelMapper.Select <TEntity>(connection, predicate)); } } catch (Exception ex) { throw new Exception(ex.Message); } }