예제 #1
0
        public void SQLiteTest()
        {
            var builder = new SqliteQueryBuilder();

            Assert.Equal(" json_extract(Data, '$.value') = 100", builder.Build(QParser.Parse("$.value = 100").Expression));
            Assert.Equal(" json_extract(Data, '$.Text') like '%'", builder.Build(QParser.Parse("$.Text like '%'").Expression));
            Assert.Equal(" json_extract(Data, '$.value') = 100 and  json_extract(Data, '$.value') = 100",
                         builder.Build(QParser.Parse("$.value = 100 and $.value = 100").Expression));
            Assert.Equal(" json_extract(Data, '$.value') = 100 and ( json_extract(Data, '$.value') = 100 or  json_extract(Data, '$.value') = 100)",
                         builder.Build(QParser.Parse("$.value = 100 and ($.value = 100 or $.value = 100)").Expression));
        }
예제 #2
0
        public static IQueryBuilder <TDatabase> GetQueryBuilder <TDatabase>()
        {
            var connection = new SqliteConnection(@"Data Source=:memory:");

            connection.Open();

            var queryBuilder = new SqliteQueryBuilder <TDatabase>(connection);

            var createDatabase = Migration.Migration.CreateDatabase(queryBuilder.DatabaseModel);

            // Allow for the database creation query to be empty for empty databases
            if (!string.IsNullOrEmpty(createDatabase))
            {
                var command = connection.CreateCommand();

                command.CommandText = createDatabase;
                command.ExecuteNonQuery();
            }

            return(queryBuilder);
        }