Ejemplo n.º 1
0
        public void Test_Avg()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>()
                .SetProjection(Projections.Avg("Age"));

            DetachedCriteria actual =
                DetachedCriteria.For <Person>()
                .SetProjection(LambdaProjection.Avg <Person>(p => p.Age));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void Test_GroupProperty()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>()
                .SetProjection(Projections.GroupProperty("Name"));

            DetachedCriteria actual =
                DetachedCriteria.For <Person>()
                .SetProjection(LambdaProjection.GroupProperty <Person>(p => p.Name));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void TestCountDistinct()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>()
                .SetProjection(Projections.CountDistinct("Name"));

            DetachedCriteria actual =
                DetachedCriteria.For <Person>()
                .SetProjection(LambdaProjection.CountDistinct <Person>(p => p.Name));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void Test_AliasedProperty()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>("personAlias")
                .SetProjection(Projections.Property("personAlias.Age"));

            Person           personAlias = null;
            DetachedCriteria actual      =
                DetachedCriteria <Person> .Create(() => personAlias)
                .SetProjection(LambdaProjection.Property(() => personAlias.Age));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void Test_PropertyAliasUsingFluentInterface()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>()
                .SetProjection(Projections.Property("Age").As("ageAlias"));

            int ageAlias            = 0;
            DetachedCriteria actual =
                DetachedCriteria.For <Person>()
                .SetProjection(LambdaProjection.Property <Person>(p => p.Age).As(() => ageAlias));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void TestPropertyAliasWithValueType()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>()
                .SetProjection(Projections.Alias(Projections.Property("Age"), "ageAlias"));

            int ageAlias            = 0;
            DetachedCriteria actual =
                DetachedCriteria.For <Person>()
                .SetProjection(LambdaProjection.Alias(LambdaProjection.Property <Person>(p => p.Age), () => ageAlias));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void Test_PropertyUsingAlias()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>()
                .SetProjection(Projections.Alias(Projections.Property("Name"), "nameAlias"));

            string           nameAlias = null;
            DetachedCriteria actual    =
                DetachedCriteria.For <Person>()
                .SetProjection(LambdaProjection.Alias(LambdaProjection.Property <Person>(p => p.Name), () => nameAlias));

            AssertCriteriaAreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public void TestCountDistinctUsingAlias()
        {
            DetachedCriteria expected =
                DetachedCriteria.For <Person>("personAlias")
                .SetProjection(Projections.CountDistinct("personAlias.Age"));

            Person           personAlias = null;
            DetachedCriteria actual      =
                DetachedCriteria <Person> .Create(() => personAlias)
                .SetProjection(LambdaProjection.CountDistinct(() => personAlias.Age));

            AssertCriteriaAreEqual(expected, actual);
        }