Beispiel #1
0
        public ExpressionToSql <T> Count(Expression <Func <T, object> > expression = null)
        {
            this.Clear();
            if (expression == null)
            {
                string tableName = typeof(T).Name;

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

                if (!string.IsNullOrWhiteSpace(tableAlias))
                {
                    tableName += " " + tableAlias;
                }
                this._sqlBuilder.AppendFormat("select count(*) from {0}", tableName);
            }
            else
            {
                Expression2SqlProvider.Count(expression.Body, this._sqlBuilder);
            }

            return(this);
        }
Beispiel #2
0
 protected override SqlBuilder Count(UnaryExpression expression, SqlBuilder sqlBuilder)
 {
     Expression2SqlProvider.Count(expression.Operand, sqlBuilder);
     return(sqlBuilder);
 }
 protected override SqlBuilder Count(ParameterExpression expression, SqlBuilder sqlBuilder)
 {
     Expression2SqlProvider.Count(expression, sqlBuilder);
     return(sqlBuilder);
 }