Esempio n. 1
0
        public void VarProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            double result = source.QueryScalar <Person, double>("SELECT var(age) FROM this");

            Assert.IsTrue(result == source.Variance(p => p.Age));
        }
Esempio n. 2
0
        public void SelectIdentityReferenceType()
        {
            var source = TestData.GetPeople();
            var result = source.Query <Person>("SELECT * FROM this");

            Assert.IsTrue(result.SequenceEqual(source));
        }
Esempio n. 3
0
        public void SelectWhereFalse()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <int>    result = source.Query <Person, int>("SELECT age FROM this WHERE FALSE");

            Assert.IsFalse(result.Any());
        }
Esempio n. 4
0
        public void DynamicOneProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, dynamic>("SELECT address FROM this");

            Assert.IsTrue(result.SequenceEqual(source.Select(p => p.Address)));
        }
Esempio n. 5
0
        public void WherePropertyNotEqualVB()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <Person> result = source.Query <Person>("SELECT * FROM this WHERE age <> 40");

            Assert.IsTrue(result.SequenceEqual(source.Where(p => p.Age != 40)));
        }
Esempio n. 6
0
        public void SelectProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <int>    result = source.Query <Person, int>("SELECT age FROM this");

            Assert.IsTrue(result.SequenceEqual(source.Select(p => p.Age)));
        }
Esempio n. 7
0
        public void DistinctProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <string> result = source.Query <Person, string>("SELECT DISTINCT address FROM this");

            Assert.IsTrue(result.SequenceEqual(source.Select(p => p.Address).Distinct()));
        }
Esempio n. 8
0
        public void OrderByPropertySelectOtherProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <string> result = source.Query <Person, string>("SELECT Name FROM this ORDER BY age");

            Assert.IsTrue(result.SequenceEqual(source.OrderBy(p => p.Age).Select(p => p.Name)));
        }
Esempio n. 9
0
        public void SelectPropertyWhereWithAddition()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <int>    result = source.Query <Person, int>("SELECT age FROM this WHERE age = 39 + 1");

            Assert.IsTrue(result.SequenceEqual(source.Where(p => p.Age == 39 + 1).Select(p => p.Age)));
        }
Esempio n. 10
0
        public void OrderByPropertyDescending()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <Person> result = source.Query <Person>("SELECT * FROM this ORDER BY age DESC");

            Assert.IsTrue(result.SequenceEqual(source.OrderByDescending(p => p.Age)));
        }
Esempio n. 11
0
        public void PropertyWhere()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <int>    result = source.Query <Person, int>("SELECT Age FROM this WHERE age > 40");

            Assert.IsTrue(result.SequenceEqual(source.Where(p => p.Age > 40).Select <Person, int>(p => p.Age)));
        }
Esempio n. 12
0
        public void SelectPropertyWhereOtherProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <int>    result = source.Query <Person, int>("SELECT age FROM this WHERE name = 'Frank'");

            Assert.IsTrue(result.SequenceEqual(source.Where(p => p.Name == "Frank").Select(p => p.Age)));
        }
Esempio n. 13
0
        public void SelectOnePropertyWhereOtherProperty2()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            int result = source.QueryScalar <Person, int>("SELECT Age FROM this WHERE name = 'Frank'");

            Assert.IsTrue(result == source.Where(p => p.Name == "Frank").Select <Person, int>(p => p.Age).First());
        }
Esempio n. 14
0
        public void AvgProperty()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            double result = source.QueryScalar <Person, double>("SELECT avg(AGE) FROM this");

            Assert.IsTrue(result == source.Average(p => p.Age));
        }
Esempio n. 15
0
        public void ScalarAggregateIntoObject()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.QueryScalar <Person, object>("SELECT avg(AGE) FROM this");

            Assert.IsTrue(result.Equals(source.Average(p => p.Age)));
        }
Esempio n. 16
0
        public void CountAll()
        {
            var source = TestData.GetPeople();
            int result = source.QueryScalar <Person, int>("SELECT count(ALL address) FROM this");

            Assert.IsTrue(result == source.Where(p => p.Address != null).Count());
        }
Esempio n. 17
0
        public void CountDistinctWhere()
        {
            var source = TestData.GetPeople();
            int result = source.QueryScalar <Person, int>("SELECT count(DISTINCT address) FROM this WHERE age > 40");

            Assert.IsTrue(result == source.Where(p => p.Age > 40).Select(p => p.Address).Where(s => s != null).Distinct().Count());
        }
Esempio n. 18
0
        public void TwoAggregatesIntoExpando()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, dynamic>("SELECT avg(AGE) AS a, stdev(AGE) AS s FROM this").First();

            Assert.IsTrue(result.a == source.Average(p => p.Age));
            Assert.IsTrue(result.s == source.StandardDeviation(p => p.Age));
        }
Esempio n. 19
0
        public void TwoAggregatesIntoTypedDictionary()
        {
            IEnumerable <Person>         source = TestData.GetPeople();
            IDictionary <string, double> result = source.Query <Person, IDictionary <string, double> >("SELECT avg(AGE) AS a, stdev(AGE) AS s FROM this").First();

            Assert.IsTrue(result["a"] == source.Average(p => p.Age));
            Assert.IsTrue(result["s"] == source.StandardDeviation(p => p.Age));
        }
Esempio n. 20
0
        public void OrderByTwoProperties()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <Person> result = source.Query <Person>("SELECT * FROM this ORDER BY age, name");
            IEnumerable <Person> answer = source.OrderBy(p => p.Age).ThenBy(p => p.Name);

            Assert.IsTrue(result.SequenceEqual(answer));
        }
Esempio n. 21
0
        public void CountDistinctIgnoresNullProperties()
        {
            var source   = TestData.GetPeople();
            int distinct = source.QueryScalar <Person, int>("SELECT count(DISTINCT address) FROM this");
            int notnull  = source.QueryScalar <Person, int>("SELECT count(DISTINCT address) FROM this WHERE address IS NOT NULL");

            Assert.IsTrue(distinct == notnull);
        }
Esempio n. 22
0
        public void LikeContains()
        {
            var source = TestData.GetPeople();
            var result = source.Query <Person>("SELECT * FROM this WHERE Name LIKE '%e%'");
            var answer = source.Where(p => p.Name.IndexOf("e", StringComparison.OrdinalIgnoreCase) > -1);

            Assert.IsTrue(result.SequenceEqual(answer));
        }
Esempio n. 23
0
        public void LikeNonASCIICharacter()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            IEnumerable <Person> result = source.Query <Person>("SELECT * FROM this WHERE name LIKE 'Ø%'");
            var answer = source.Where(p => p.Name.StartsWith("Ø"));

            Assert.IsTrue(result.SequenceEqual(answer));
        }
Esempio n. 24
0
        public void TwoAggregatesIntoTuple()
        {
            IEnumerable <Person>   source = TestData.GetPeople();
            Tuple <double, double> result = source.Query <Person, Tuple <double, double> >("SELECT avg(AGE) AS a, stdev(AGE) AS s FROM this").First();

            Assert.IsTrue(result.Item1 == source.Average(p => p.Age));
            Assert.IsTrue(result.Item2 == source.StandardDeviation(p => p.Age));
        }
Esempio n. 25
0
        public void NewObjectThreePropertiesConstructor()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, Tuple <string, int, string> >("SELECT name, age, address FROM this");

            var answer = from p in source select new Tuple <string, int, string>(p.Name, p.Age, p.Address);

            Assert.IsTrue(result.SequenceEqual(answer));
        }
Esempio n. 26
0
        public void ExpressionOnFields2()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, string>("SELECT name FROM this WHERE (weight / 2)  > (age * 2)");
            var answer = source.Where(p => p.Weight / 2 > p.Age * 2).Select(p => p.Name);

            Assert.IsTrue(result.Any());
            Assert.IsTrue(answer.SequenceEqual(result));
        }
Esempio n. 27
0
        public void CompareFields()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, string>("SELECT name FROM this WHERE age > weight");
            var answer = source.Where(p => p.Age > p.Weight).Select(p => p.Name);

            Assert.IsTrue(result.Any());
            Assert.IsTrue(answer.SequenceEqual(result));
        }
Esempio n. 28
0
        public void DistinctMultipleProperties()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, Tuple <string, string> >("SELECT DISTINCT name, address FROM this");

            var answer = (from p in source
                          select new Tuple <string, string>(p.Name, p.Address)).Distinct();

            Assert.IsTrue(result.SequenceEqual(answer));
        }
Esempio n. 29
0
        public void NewObjectTwoPropertiesWithAs()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, FamilyMember>("SELECT name, address AS location FROM this");

            var answer = from p in source select new FamilyMember {
                Name = p.Name, Location = p.Address
            };

            Assert.IsTrue(result.SequenceEqual(answer));
        }
Esempio n. 30
0
        public void NewObjectTwoProperties()
        {
            IEnumerable <Person> source = TestData.GetPeople();
            var result = source.Query <Person, BasicPerson>("SELECT name, address FROM this");

            var answer = from p in source select new BasicPerson {
                Name = p.Name, Address = p.Address
            };

            Assert.IsTrue(result.SequenceEqual(answer));
        }