DotNetNext / SqlSugar

.Net aot ORM Fastest ORM Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
https://www.donet5.com/Home/Doc
MIT License
5.24k stars 1.33k forks source link

完善了oracle获取表结构,mysql创建表字段默认值问题。 #1153

Closed henq closed 11 months ago

henq commented 1 year ago

原oracle获取字段代码bug修复。

DotNetNext commented 1 year ago

创建表的方法用下面的,不要改原始方法了

var type = db.DynamicBuilder().CreateClass("table1", new SugarTable()
    {
    })
    .CreateProperty("Id", typeof(int),new SugarColumn() { IsPrimaryKey = true, IsIdentity = true })
    .CreateProperty("Name",typeof(string), new SugarColumn() { })
    .WithCache()//缓存起来根据表名和字段名组合的KEY    
    .BuilderType();
    //SugarColumn 属性说明看文档: 迁移

     //创建表
    db.CodeFirst.InitTables(type); //建表属性API看迁移  
DotNetNext commented 1 year ago

还有长度是准确的 还有类型用这个 db.DbMaintenance.GetColumnInfosByTableName("s")[0].OracleDataType

henq commented 1 year ago

创建表的方法用下面的,不要改原始方法了

var type = db.DynamicBuilder().CreateClass("table1", new SugarTable()
    {
    })
    .CreateProperty("Id", typeof(int),new SugarColumn() { IsPrimaryKey = true, IsIdentity = true })
    .CreateProperty("Name",typeof(string), new SugarColumn() { })
    .WithCache()//缓存起来根据表名和字段名组合的KEY    
    .BuilderType();
    //SugarColumn 属性说明看文档: 迁移

     //创建表
    db.CodeFirst.InitTables(type); //建表属性API看迁移  

我建表用的这个方法,程序里动态构建表的。 Store.Db.DbMaintenance.CreateTable(dto.DbTableName, columns);建表时实体对象还不存在,不能用你给的这个方法。 用这个方法建表,时候,类型字段有问题。 还有长度是准确的 还有类型用这个 db.DbMaintenance.GetColumnInfosByTableName("s")[0].OracleDataType Oracle数据库下原有的方法获取文本类型长度是对的,但是NUMBER类型时候,长度,精度,有问题。类型获取的不是oracle的data_type,和其它数据库返回的类型不一致。新改的把获取oracle列注释的问题也修复了。

DotNetNext commented 1 year ago

这个方法不推荐用了,是coedfirst底层方法, 有些库需要手动处理兼容。推荐用 db.DynamicBuilder().CreateClass("table1", new SugarTable() 所有库兼容都处理好了