Exemplo n.º 1
0
        public void Normal_Insert()
        {
            int ID;
            var userInfo = new UserVO() { UserName = "******", GetDate = DateTime.Now };
            var insertUser = new InsertUserVO() { PassWord = "******", UserName = "******" };

            // 将标识设置到标识字段
            Table.Data.User.Insert(userInfo, true); Assert.IsTrue(userInfo.ID > 0);

            // 设置out ID
            userInfo.ID++; Table.Data.User.Insert(userInfo, out ID); Assert.IsTrue(userInfo.ID > 0 && userInfo.ID == ID);

            // 缓存表
            Table.Data.UserRole.Insert(new UserRoleVO { Caption = "标题", Descr = "不清楚" });

            // 不同逻辑删除方式新入(主键为GUID)
            Table.Data.Orders.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-1", CreateAt = DateTime.Now, CreateName = "用户1" });
            Table.Data.OrdersAt.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-2", CreateAt = DateTime.Now, CreateName = "用户1" });
            Table.Data.OrdersBool.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-3", CreateAt = DateTime.Now, CreateName = "用户1" });
            Table.Data.OrdersNum.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-4", CreateAt = DateTime.Now, CreateName = "用户1" });
            Table.Data.OrdersBoolCache.Insert(new OrdersVO { ID = Guid.NewGuid(), OrderNo = "12345678-5", CreateAt = DateTime.Now, CreateName = "用户1" });

            // 存储过程
            Table.Data.InsertUser.Execute(insertUser); Assert.IsTrue(insertUser.ID > 0);

            // 配置SQL
            Table.Data.InsertNewUser.Execute();

            // 手动SQL
            var table = Table.Data; table.ManualSql.Execute("INSERT INTO Members_User (UserName,PassWord) VALUES(@UserName,@PassWord)", table.DbProvider.CreateDbParam("UserName", "steden1"), table.DbProvider.CreateDbParam("PassWord", "steden1"));

        }
Exemplo n.º 2
0
 public void ExecuteTestMethod()
 {
     var info = new InsertUserVO { UserName = "******", PassWord = "******" };
     Proc.Data.InsertUser.Execute(info);
     Assert.IsTrue(info.ID > 1);
 }