コード例 #1
0
 public DistinctShould()
 {
     var(q, v, c)   = Builder.InitializeBasicItemsForQueryData("some field");
     _query         = q;
     _validColumns  = v;
     _clauseFactory = c;
 }
コード例 #2
0
 public QueryData(Query query, IValidColumns validColumns, ClauseFactory clauseFactory, string tableName)
 {
     _clauseFactory = clauseFactory;
     _query         = query;
     _validColumns  = validColumns;
     TableName      = tableName;
 }
コード例 #3
0
        public static QueryData BuildQueryData(Query query, IValidColumns validColumns = null)
        {
            var columns =
                validColumns
                ?? BuildValidColumns();

            return(new QueryData(
                       query,
                       columns,
                       BuildClauseFactory(columns),
                       "[MySchema].[MyTable]"
                       ));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public ClauseFactory(IValidColumns validColumns)
 {
     _validColumns = validColumns;
 }
コード例 #6
0
        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));
        }
コード例 #7
0
 public static ClauseFactory BuildClauseFactory(IValidColumns validColumns = null, Func <Filter, IEnumerable <Clause> > clauseBuilder = null)
 {
     return(BuildFakeClauseFactory(validColumns, clauseBuilder).Object);
 }
コード例 #8
0
 public ClauseFactoryShould()
 {
     _fakeValidColumns = Builder.BuildFakeValidColumns().Object;
 }
コード例 #9
0
        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);
        }