Пример #1
0
        public static string TestCustomSelectString(ISQLQueryWriter writer)
        {
            var query = QueryModelFactory.CreateSelect(new ComplexColumn("count(*)"))
                        .From(table1);

            return(writer.CreateSelectQuery(query));
        }
        public static string Delete(ISQLQueryWriter writer)
        {
            var q = QueryModelFactory.CreateDelete(table, new List <WhereDefinition>()
            {
                new WhereDefinition(col1, "=", 1)
            });

            return(writer.CreateDeleteQuery(q));
        }
Пример #3
0
        public static string TestUpdate(ISQLQueryWriter writer)
        {
            var query = new UpdateModel(table,
                                        new List <WhereDefinition>()
            {
                new WhereDefinition(col1, "=", 1),
                new WhereDefinition(WhereType.And, col2, "=", "test")
            },
                                        new List <KeyValuePair <FieldColumn, object> >()
            {
                new KeyValuePair <FieldColumn, object>(col3, 1),
                new KeyValuePair <FieldColumn, object>(col4, "test2")
            });

            return(writer.CreateUpdateQuery(query));
        }
Пример #4
0
        public static string TestComplexSelect(ISQLQueryWriter writer)
        {
            var query = QueryModelFactory.CreateSelect(col1, col4, col6, count)
                        .From(table1)
                        .Where(
                new WhereDefinition(col1, "=", 1),
                new WhereDefinition(WhereType.And, col4, "=", 2),
                new WhereDefinition(WhereType.Or, count, ">", 3)
                )
                        .Join(
                new JoinDefinition(JoinDefinition.JoinType.INNER, table2, col1, col4),
                new JoinDefinition(JoinDefinition.JoinType.INNER, table3, col2, col5, col3, col6)
                )
                        .OrderBy(
                new OrderByDefinition(count),
                new OrderByDefinition(col4, OrderByDefinition.SortDirection.Descending)
                )
                        .GroupBy(col1, col4);

            return(writer.CreateSelectQuery(query));
        }
        public static string TestInsert(ISQLQueryWriter writer)
        {
            var query = QueryModelFactory.CreateInsert(table, values.Values.ToList());

            return(writer.CreateInsertQuery(query));
        }
        public static string DeleteAll(ISQLQueryWriter writer)
        {
            var q = QueryModelFactory.CreateDeleteAll(table);

            return(writer.CreateDeleteQuery(q));
        }