动态类型创建表怎么用Fastest,还有怎么查询 返回

SqlSugar 沟通中
5 189
该叫什么 朽木 发布于2周前
悬赏:0 飞吻

比如下图中报表查询的说明, 假如我创建的是一个多字段的表,后续写入数据和查询怎么写。

db.DynamicBuilder().CreateClass(tableName, new SugarTable())
                    .CreateProperty("f1", typeof(string), new SugarColumn { IsPrimaryKey = true })
                    .CreateProperty("f2", typeof(string), new SugarColumn { IsPrimaryKey = true })
                    .CreateProperty("f3", typeof(string), new SugarColumn { IsPrimaryKey = true })
                    .CreateProperty("f4", typeof(string), new SugarColumn { IsPrimaryKey = true })
                    .BuilderType();

image.png

热忱回答5

  •   //可以是List<Dictionary<string, object>()
          
        db.InsertableByObject(value).ExecuteCommand();
        db.UpdateableByObject(value).ExecuteCommand();
        db.DeleteableByObject(value).ExecuteCommand();
        db.StorageableByObject(value).ExecuteCommand();//插入或者更新
        //查询 带有类功能 5.1.4.84 
        // API和无实体查询类似
        db.QueryableByObject(type).ToList();


    0 回复
  • https://www.donet5.com/Home/Doc?typeId=2569

    0 回复
  • @fate sta:感谢,太方便了

    0 回复
  • @fate sta:大佬,还有怎么复制一个已有的实体对应的表结构临时用呢

    0 回复
  • 写个方法循环一下。。构造了type就行了

    0 回复