Exemplo n.º 1
0
        /// <summary>
        /// Check if exist elements in the table which match condition; otherwise, false.
        /// </summary>
        /// <param name="whereCondition">The where condition.</param>
        /// <param name="args">The arguments for where.</param>
        /// <returns>
        /// <see langword="true"/> if exist elements in the table which match condition; otherwise, <see langword="false"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">if <c>whereCondition</c> is null or white string.</exception>
        /// <example>
        ///   <code source="..\Examples\Kros.KORM.Examples\IQueryExample.cs" title="Any" region="Any" lang="C#" />
        /// </example>
        public bool Any(RawSqlString whereCondition, params object[] args)
        {
            Check.NotNullOrWhiteSpace(whereCondition.Format, nameof(whereCondition));
            const string top = "TOP 1 1";

            this.SelectExpression.SetColumnsExpression(new ColumnsExpression(top));
            this.SelectExpression.SetWhereExpression(new WhereExpression(whereCondition, args));

            return(_provider.ExecuteScalar <T>(this) != null);
        }