Exemple #1
0
        public SqlQueryable <T> Count(Expression <Func <T, object> > expression = null)
        {
            this._sqlBuilder.SetSqlCommandType(SqlCommandType.Calculate);
            this.Clear();
            if (expression == null)
            {
                string tableName = typeof(T).GetTableName(_sqlBuilder._dbSqlParser);

                this._sqlBuilder.SetTableAlias(tableName);
                string tableAlias = this._sqlBuilder.GetTableAlias(tableName);

                if (!string.IsNullOrWhiteSpace(tableAlias))
                {
                    tableName += " " + tableAlias;
                }
                this._sqlBuilder.SqlCalculateStr = $"select Count(*) from {tableName}";
            }
            else
            {
                SqlProvider.Count(expression.Body, this._sqlBuilder);
            }

            return(this);
        }
 protected override SqlBuilder Count(ParameterExpression expression, SqlBuilder sqlBuilder)
 {
     SqlProvider.Count(expression, sqlBuilder);
     return(sqlBuilder);
 }
Exemple #3
0
 protected override SqlBuilder Count(UnaryExpression expression, SqlBuilder sqlBuilder)
 {
     SqlProvider.Count(expression.Operand, sqlBuilder);
     return(sqlBuilder);
 }