예제 #1
0
        public void BuildLoadExpr_WithGuardNulls()
        {
            var expr = new DataSourceExpressionBuilder <Tuple <DateTime?> >(CreateFullStuffedLoadOptions(), true).BuildLoadExpr();

            Assert.Equal(
                "data"
                // All selectors are guarded and use conversion to Nullable
                + $".Where(obj => ({FormatExpectedSelectorExpr(true, true)} == 123))"
                + $".OrderBy(obj => {FormatExpectedSelectorExpr(true, true)})"
                + ".Select(obj => new AnonType`1("
                + $"I0 = {FormatExpectedSelectorExpr(true, true)}"
                + "))",
                expr.ToString()
                );
        }
예제 #2
0
        public void BuildLoadExpr_NoGuardNulls()
        {
            var expr = new DataSourceExpressionBuilder <Tuple <DateTime?> >(CreateFullStuffedLoadOptions(), false).BuildLoadExpr();

            Assert.Equal(
                "data"
                // Where and OrderBy use simple selectors
                + $".Where(obj => ({FormatExpectedSelectorExpr(false, false)} == 123))"
                + $".OrderBy(obj => {FormatExpectedSelectorExpr(false, false)})"

                // Select uses conversion to Nullable
                + ".Select(obj => new AnonType`1() {"
                + $"I0 = {FormatExpectedSelectorExpr(true, false)}"
                + "})",
                expr.ToString()
                );
        }
예제 #3
0
        public void BuildLoadGroupsExpr_NoGuardNulls()
        {
            var expr = new DataSourceExpressionBuilder <Tuple <DateTime?> >(CreateFullStuffedLoadOptions(), false).BuildLoadGroupsExpr();

            Assert.Equal(
                // Only selectors that land in .Select() use conversion to Nullable
                "data"
                + $".Where(obj => ({FormatExpectedSelectorExpr(false, false)} == 123))"
                + $".GroupBy(obj => new AnonType`1(I0 = {FormatExpectedSelectorExpr(true, false)}))"
                + ".OrderBy(g => g.Key.I0)"
                + ".Select(g => new AnonType`4("
                + "I0 = g.Count(), "
                + "I1 = g.Key.I0, "
                + $"I2 = g.Max(obj => {FormatExpectedSelectorExpr(true, false)}), "
                + $"I3 = g.Max(obj => {FormatExpectedSelectorExpr(true, false)})"
                + "))",
                expr.ToString()
                );
        }