コード例 #1
0
        public void BuildQueryTest()
        {
            var model = MakeTestSqlModel();
            var mockRunntimeContext = new MockRuntimContext();

            Runtime.RuntimeContext.Init(mockRunntimeContext, 10410);
            mockRunntimeContext.AddModel(model);

            var q = new SqlQuery(model.Id);

            q.Where(q.T["Code"] >= 1 & q.T["Code"] < 10);
            SqlQuery.AddAllSelects(q, model, q.T, null); //Test only

            var store = new PgSqlStore(StoreSettings);
            var cmd   = store.BuildQuery(q);

            Assert.True(cmd != null);
            output.WriteLine(cmd.CommandText);
        }
コード例 #2
0
        public void BuildUpdateTest()
        {
            var model = MakeTestSqlModel();
            var mockRunntimeContext = new MockRuntimContext();

            Runtime.RuntimeContext.Init(mockRunntimeContext, 10410);
            mockRunntimeContext.AddModel(model);

            var q = new SqlUpdateCommand(model.Id);

            q.Update(q.T["Code"].Assign(q.T["Code"] + 1));
            q.Where(q.T["Code"] == 2);

            var outs = q.Output(r => r.GetInt32(0), q.T["Code"]);
            //var outs = q.Output(r => new { Code = r.GetInt32(0), Name = r.GetString(1) }, q.T["Code"], q.T["Name"]);
            //outs[0].Code == 3;

            var store = new PgSqlStore(StoreSettings);
            var cmd   = store.BuidUpdateCommand(q);

            Assert.True(cmd != null);
            output.WriteLine(cmd.CommandText);
            //Update "Emploee" t Set "Code" = "Code" + @p1 Where t."Code" = @p2 RETURNING "Code"
        }