public int Count(Expression <Func <T, bool> > whereExpression)
        {
            if (whereExpression != null)
            {
                _sqlExpression = _sqlExpression.Where(whereExpression);
            }

            var sql = _buildComplexSql.BuildJoin(_database, _sqlExpression, _joinSqlExpressions.Values.ToList(), null, true);

            return(_database.ExecuteScalar <int>(sql));
        }
Exemple #2
0
        protected Sql BuildSql()
        {
            Sql sql;

            if (_joinSqlExpressions.Any())
            {
                sql = _buildComplexSql.BuildJoin(_database, _sqlExpression, _joinSqlExpressions.Values.ToList(), null, false, false);
            }
            else
            {
                sql = new Sql(true, _sqlExpression.Context.ToSelectStatement(), _sqlExpression.Context.Params);
            }
            return(sql);
        }