Пример #1
0
        public void Test1()
        {
            var t1 = new Table("table_1");
            var c1 = new Column("name", t1, null);
            var c2 = new Column("city", t1, null);

            var g = new Generator.PlugIn.BaseSqlGenerator.SqlGeneratorPlugin();

            _columns.Add(c1);
            _columns.Add(c2);
            _tables.Add(t1);

            Assert.AreEqual(
                "SELECT table_1.name, table_1.city FROM table_1",
                g.GetSql(_tables, _columns, _keyPairs)
                );
        }
Пример #2
0
        public void Test5()
        {
            var orders   = new Table("orders");
            var products = new Table("products");
            var number   = new Column("number", orders, null);
            var cost     = new Column("price", products, "SUM");
            var k1       = new KeyPair(products, "id", orders, "order_id");

            var g = new Generator.PlugIn.BaseSqlGenerator.SqlGeneratorPlugin();

            _columns.Add(number);
            _columns.Add(cost);
            _tables.Add(orders);
            _tables.Add(products);
            _keyPairs.Add(k1);

            Assert.AreEqual(
                "SELECT orders.number, SUM(products.price) FROM products JOIN orders ON products.order_id = orders.id GROUP BY orders.number",
                g.GetSql(_tables, _columns, _keyPairs)
                );
        }
Пример #3
0
        public void Test3()
        {
            var t1 = new Table("table_1");
            var t2 = new Table("table_2");
            var c1 = new Column("name", t1, null);
            var c2 = new Column("city", t1, null);
            var c3 = new Column("family_name", t2, null);
            var k1 = new KeyPair(t2, "id", t1, "family_id");

            var g = new Generator.PlugIn.BaseSqlGenerator.SqlGeneratorPlugin();

            _columns.Add(c1);
            _columns.Add(c2);
            _columns.Add(c3);
            _tables.Add(t1);
            _tables.Add(t2);
            _keyPairs.Add(k1);

            Assert.AreEqual(
                "SELECT table_1.name, table_1.city, table_2.family_name FROM table_2 JOIN table_1 ON table_2.family_id = table_1.id",
                g.GetSql(_tables, _columns, _keyPairs)
                );
        }