Exemple #1
0
        public void ItShouldHandleASimpleIntersect()
        {
            var stream =
                AST.SqlExpression.NewSelect(
                    AST.SelectExpression.NewPlain(
                        AST.PlainSelectExpression.NewSet(
                            S.Intersect(
                                S.PlainSelect(
                                    S.Select(S.Star <Person>()),
                                    S.From <Person>()),
                                S.PlainSelect(
                                    S.Select(S.Star <Person>()),
                                    S.From <Person>(),
                                    S.Where(
                                        S.BinExp(S.Col <Person>("Age"), AST.BinaryOperation.GreaterThan, S.Const(42))))))));
            var result = SqlGen.SqlifyExpression(AnsiSql.Dialect, stream);

            var expected =
                "SELECT PersonRef.* FROM Person PersonRef " +
                "INTERSECT " +
                "SELECT PersonRef.* FROM Person PersonRef WHERE PersonRef.Age > 42";

            Assert.That(result, Is.EqualTo(expected));
        }