public DistinctShould() { var(q, v, c) = Builder.InitializeBasicItemsForQueryData("some field"); _query = q; _validColumns = v; _clauseFactory = c; }
public QueryData(Query query, IValidColumns validColumns, ClauseFactory clauseFactory, string tableName) { _clauseFactory = clauseFactory; _query = query; _validColumns = validColumns; TableName = tableName; }
public static QueryData BuildQueryData(Query query, IValidColumns validColumns = null) { var columns = validColumns ?? BuildValidColumns(); return(new QueryData( query, columns, BuildClauseFactory(columns), "[MySchema].[MyTable]" )); }
public static Mock <ClauseFactory> BuildFakeClauseFactory(IValidColumns validColumns = null, Func <Filter, IEnumerable <Clause> > clauseBuilder = null) { var columnValidator = validColumns ?? BuildValidColumns(); var fakeClauseFactory = new Mock <ClauseFactory>(columnValidator); if (clauseBuilder != null) { fakeClauseFactory .Setup(factory => factory.Build(It.IsAny <Filter>())) .Returns(clauseBuilder); } return(fakeClauseFactory); }
public ClauseFactory(IValidColumns validColumns) { _validColumns = validColumns; }
public static QueryData BuildQueryData(string[] fields, Filter[] filters = null, string[] groupBy = null, bool?distinct = null, string direction = null, string sort = null, IValidColumns validColumns = null) { var query = BuildQuery(fields, filters, groupBy, distinct, direction, sort); return(BuildQueryData(query, validColumns)); }
public static ClauseFactory BuildClauseFactory(IValidColumns validColumns = null, Func <Filter, IEnumerable <Clause> > clauseBuilder = null) { return(BuildFakeClauseFactory(validColumns, clauseBuilder).Object); }
public ClauseFactoryShould() { _fakeValidColumns = Builder.BuildFakeValidColumns().Object; }
public virtual (string, IEnumerable <(string, object)> parameter) BuildQuery(Query query, IValidColumns validColumns, string tableName) { var queryData = new QueryData(query, validColumns, new ClauseFactory(validColumns), tableName); var whereGenerator = new WhereGenerator(queryData); var groupByGenerator = new GroupByGenerator(queryData); var orderByGenerator = new OrderByGenerator(queryData); var parameter = whereGenerator.GetParameters(); return( new SqlQueryGenerator( new SelectGenerator(queryData), whereGenerator, groupByGenerator, orderByGenerator ).ToString() , parameter); }