Exemplo n.º 1
0
 private void InsertPeople()
 {
     QueryTests.Insert(new Person {
         Age = 25, Name = "jane"
     });
     QueryTests.Insert(new Person {
         Age = 60, Name = "deb"
     });
     QueryTests.Insert(new Person {
         Age = 63, Name = "bob"
     });
     QueryTests.Insert(new Person {
         Age = 74, Name = "alicia"
     });
     QueryTests.Insert(new Person {
         Age = 34, Name = "joe"
     });
     QueryTests.Insert(new Person {
         Age = 29, Name = "deb"
     });
     QueryTests.Insert(new Person {
         Age = 21, Name = "carl"
     });
     QueryTests.Insert(new Person {
         Age = 45, Name = "betty"
     });
 }
Exemplo n.º 2
0
        public void LinqContains()
        {
            QueryTests.Insert(new House {
                Description = "this is a nice house"
            });
            QueryTests.Insert(new House {
                Description = "not it is not"
            });

            Console.WriteLine("houses with nice in description:");
            QueryTests.AsQueryable <House>()
            .Where(h => h.Description.Contains("nice"))
            .ToList()
            .ForEach(h => Console.WriteLine(h.Description));
        }
        public void testSQLQueryFormatter100()
        {
            Query q = new Query(StudentDTD.STUDENTPERSONAL);

            q.AddCondition("Name/FirstName", ComparisonOperators.LE, "Sally");

            // Convert the query to XML and back
            Query reparsed = QueryTests.SaveToXMLAndReparse(q, SifVersion.LATEST);

            IDictionary fields = new Hashtable();

            fields["Name/FirstName"] =
                new SQLField("Users.FName", DbType.String);

            SQLQueryFormatter formatter = new SQLQueryFormatter();
            String            sql       = formatter.Format(reparsed, fields);

            Assert.AreEqual("( Users.FName <= 'Sally' )", sql, "Query format");
        }
        public void testSQLQueryFormatter050()
        {
            Query q = new Query(StudentDTD.STUDENTPERSONAL);

            q.AddCondition("Demographics/RaceList/Race/Code", ComparisonOperators.EQ, "1002");

            // Convert the query to XML and back
            Query reparsed = QueryTests.SaveToXMLAndReparse(q, SifVersion.LATEST);

            IDictionary fields = new Hashtable();

            fields["Demographics/RaceList/Race/Code"] =
                new SQLField("Users.vchFirstName{0998=I;0999=A;1000=B;1001=H;1002=W}",
                             DbType.String);

            SQLQueryFormatter formatter = new SQLQueryFormatter();
            String            sql       = formatter.Format(reparsed, fields);

            Assert.AreEqual("( Users.vchFirstName = 'W' )", sql, "Query format");
        }
Exemplo n.º 5
0
        public void Evaluation()
        {
            // find all people in their 80s
            Console.WriteLine(Query.Mod("age", 10, 8));
            // find all people who have a first name starting with A
            Console.WriteLine(Query.Matches("name", new Regex("^[aA]")));

            // arbitrary javascript, slow! use in conjunction with non where queries that hit an index or really narrow down documents first
            var where = Query.Where("this.age === 1");
            Console.WriteLine(where);
            Console.WriteLine("where matches:");
            QueryTests.Insert(new BsonDocument {
                { "age", 2 }
            });
            QueryTests.Insert(new BsonDocument {
                { "age", 1 }
            });
            QueryTests.Find(where)
            .ToList()
            .ForEach(Console.WriteLine);
        }
Exemplo n.º 6
0
        //[Route("")]
        public async Task <QueryTestsResponse> QueryTests()
        {
            var query = new QueryTests(Request.GetQueryOptions());

            return(await _queryProcessor.ProcessQuery <QueryTests, QueryTestsResponse>(query));
        }
Exemplo n.º 7
0
 private void PrintResults(AggregateArgs matchAndSort)
 {
     QueryTests.Aggregate(matchAndSort)
     .ToList()
     .ForEach(Console.WriteLine);
 }