2013-07-19 05:47:55 +02:00
|
|
|
|
using System.Text;
|
2013-05-07 04:32:43 +02:00
|
|
|
|
|
|
|
|
|
namespace Marr.Data.QGen
|
|
|
|
|
{
|
|
|
|
|
public class SqliteRowCountQueryDecorator : IQuery
|
|
|
|
|
{
|
|
|
|
|
private SelectQuery _innerQuery;
|
|
|
|
|
|
|
|
|
|
public SqliteRowCountQueryDecorator(SelectQuery innerQuery)
|
|
|
|
|
{
|
|
|
|
|
_innerQuery = innerQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Generate()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
BuildSelectCountClause(sql);
|
|
|
|
|
_innerQuery.BuildFromClause(sql);
|
|
|
|
|
_innerQuery.BuildJoinClauses(sql);
|
|
|
|
|
_innerQuery.BuildWhereClause(sql);
|
|
|
|
|
|
|
|
|
|
return sql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BuildSelectCountClause(StringBuilder sql)
|
|
|
|
|
{
|
|
|
|
|
sql.AppendLine("SELECT COUNT(*)");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|