Example #1
0
        public void SimpleAliasJoinSelect()
        {
            var r = Sql
                    .From <Cliente>()
                    .Join <Estado>().On(x => x.Item1.IdEstado == x.Item2.IdRegistro)
                    .Join <Factura>().On(x => x.Item1.IdRegistro == x.Item3.IdCliente)
                    .Alias(x => new
            {
                cli = x.Item1,
                edo = x.Item2,
                fac = x.Item3
            })
                    .Select(x => new
            {
                idCli = x.cli.IdRegistro,
                idEdo = x.edo.IdRegistro
            })
            ;

            var expected = @"
SELECT ""cli"".""IdRegistro"" AS ""idCli"", ""edo"".""IdRegistro"" AS ""idEdo""
FROM ""Cliente"" ""cli""
JOIN ""Estado"" ""edo"" ON (""cli"".""IdEstado"" = ""edo"".""IdRegistro"")
JOIN ""Factura"" ""fac"" ON (""cli"".""IdRegistro"" = ""fac"".""IdCliente"")
";

            var actual = SqlSelect.SelectToStringSP(r.Clause);

            AssertSql.AreEqual(expected, actual);
        }