Compile() публичный Метод

public Compile ( string query ) : ICompiledQuery
query string
Результат ICompiledQuery
Пример #1
0
        public void Select_CaseInsensitive_SameResult()
        {
            var compiler = new Compiler(new TestCollectionFinder());

            const string query1 = @"SELECT Foo.FooId
                                    FROM Foo
                                    WHERE Foo.FooId = 123";
            var result1 = compiler.Compile(query1).GetMongoQuery();
            const string query2 = @"select Foo.FooId
                                    from Foo
                                    where Foo.FooId = 123";
            var result2 = compiler.Compile(query2).GetMongoQuery();

            Assert.Equal(result1, result2);
        }
Пример #2
0
        public void Select_WhereByDate_DoubleQuotes_Success()
        {
            const string query = @"SELECT Foo.FooId
                                    FROM Foo
                                    WHERE Foo.DateCreated > ""2013-04-11""";
            var compiler = new Compiler(new TestCollectionFinder());
            var compiledQuery = compiler.Compile(query);
            var cleanedStatement = Regex.Replace(compiledQuery.GetMongoQuery(), "\\s+", " ").Trim();

            Assert.False(compiledQuery.HasErrors());
            Assert.Equal("{ aggregate:'foo', pipeline: [ {$match: {'dc':{$gt:new Date(\"2013-04-11\")}}}, {$project:{ '_id':1 }}, ] }", cleanedStatement);
        }
Пример #3
0
        public void SelectWithWhereGroupAndWithClauses_Success()
        {
            const string query = @"select Foo.Name, Foo.COUNT
                                  from Foo
                                  where Foo.FooId <> '521d67620e281a036092ea7e'
                                  group by Foo.Name";
            var compiler = new Compiler(new TestCollectionFinder());
            var compiledQuery = compiler.Compile(query);
            var cleanedStatement = Regex.Replace(compiledQuery.GetMongoQuery(), "\\s+", " ").Trim();

            Assert.False(compiledQuery.HasErrors());
            Assert.Equal("{ aggregate:'foo', pipeline: [ {$match: {'_id':{$ne:ObjectId('521d67620e281a036092ea7e')}}}, { $group: { _id:'$n', Foo_count: {$sum:1}} }, ] }", cleanedStatement);
        }