public ExpressionToSqlmpl <T> Count(Expression <Func <T, object> > expression = null)
        {
            this.Clear();
            if (expression == null)
            {
                string tableName = GetTableName(typeof(T).Name);

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

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

            return(this);
        }
Esempio n. 2
0
 protected override SqlBuilder Count(UnaryExpression expression, SqlBuilder sqlBuilder)
 {
     ExpressionToSqlProvider.Count(expression.Operand, sqlBuilder);
     return(sqlBuilder);
 }
Esempio n. 3
0
 protected override SqlBuilder Count(ParameterExpression expression, SqlBuilder sqlBuilder)
 {
     ExpressionToSqlProvider.Count(expression, sqlBuilder);
     return(sqlBuilder);
 }