예제 #1
0
        public void 添加部分字段_含子查询_测试lt()
        {
            var    name = "木头人3名称必须唯一" + DateTime.Now.ToString();
            string colm = "img", val = "(select value from skin limit 1 offset 1)"; DateTime cdate = DateTime.Now;
            var    insert = DBSqlite <Users> .Insert().AddColumn(p => new bool[] {
                p.UserName == name, p.Password == "666", p.CreateTime == cdate
                , SM.Sql(colm, val), SM.Sql(p.Remark, "(select '荒野高尔夫')")
            });

            Console.WriteLine(insert.RawSqlParams().Item1);
            var efrow = insert.ExecuteInsert();

            Console.WriteLine(efrow);
            string guid   = Guid.NewGuid().ToString();
            var    efrow2 = DBSqlite <LockPers> .Insert().AddColumn(p => new bool[] {
                p.Id == guid,
                p.Name == "木头人1",
                p.Content == "这是棉花好多好多",
                p.InsertTime == DateTime.Now,
                p.IsDel == false,
                p.UserId == 3
            }).ExecuteInsert();

            Console.WriteLine(efrow2);
        }
        public void AddColumnSqlTest()
        {
            string colm = "img", val = "(select value from skin limit 1 offset 1)";
            var    insert = DBSqlite <Users> .Insert().AddColumn(p => new bool[] {
                SM.Sql(colm, val), SM.Sql(p.Remark, "(select '荒野高尔夫')"),
            });

            WriteSqlParams(insert.RawSqlParams());
        }
        public void 动态添加不同字段测试()
        {
            /*
             * 测试名称:	动态添加不同字段测试
             * 测试结果:	已通过
             * 结果 的标准输出:	insert into Users (img,Remark) values ((select value from skin limit 1 offset 1),(select '荒野高尔夫'))  (age) values ((select 1))
             *
             * 问题   把多个AddColumn合并到1个
             * 将AddColumn里的sql和parms添加到 addList集合中 最后AddColumnEnd子句中执行 字段和values的join
             */

            string colm = "img", val = "(select value from skin limit 1 offset 1)";
            var    insert = DBSqlite <Users> .Insert().AddColumn(p => new bool[] {
                SM.Sql(colm, val), SM.Sql(p.Remark, "(select '荒野高尔夫')"),
            })
                            .AddColumn(p => new bool[] { SM.Sql("age", "(select 1)") });

            WriteSqlParams(insert.RawSqlParams());
        }