mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Oracle CodeFirst BUG
This commit is contained in:
parent
62f34cd145
commit
58928e07be
@ -8,29 +8,36 @@ namespace OrmTest.Demo
|
||||
{
|
||||
public class CodeTable
|
||||
{
|
||||
|
||||
[SugarColumn(IsPrimaryKey =true)]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public int Id { get; set; }
|
||||
[SugarColumn(Length = 21,OldColumnName = "Name2",ColumnDescription ="haha")]
|
||||
public string Name{ get; set; }
|
||||
[SugarColumn(IsNullable = true,Length =10)]
|
||||
[SugarColumn(Length = 21, OldColumnName = "Name2", ColumnDescription = "haha")]
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(IsNullable = true, Length = 10)]
|
||||
public string IsOk { get; set; }
|
||||
public Guid Guid { get; set; }
|
||||
[SugarColumn(ColumnDataType ="int")]
|
||||
[SugarColumn(ColumnDataType = "int")]
|
||||
public decimal Decimal { get; set; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime? DateTime { get; set; }
|
||||
[SugarColumn(IsNullable = true,OldColumnName = "Dob")]
|
||||
[SugarColumn(IsNullable = true, OldColumnName = "Dob")]
|
||||
public double? Dob2 { get; set; }
|
||||
[SugarColumn(Length =110)]
|
||||
public string A2{ get; set; }
|
||||
[SugarColumn(Length = 110)]
|
||||
public string A2 { get; set; }
|
||||
}
|
||||
public class CodeTable2 {
|
||||
public class CodeTable2
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(IsIgnore =true)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string TestId { get; set; }
|
||||
}
|
||||
public class GuidTable
|
||||
{
|
||||
public Guid Name { get; set; }
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
public class CodeFirst : DemoBase
|
||||
{
|
||||
public static void Init()
|
||||
@ -40,14 +47,15 @@ namespace OrmTest.Demo
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.Oracle,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = InitKeyType.Attribute
|
||||
InitKeyType = InitKeyType.Attribute
|
||||
});
|
||||
|
||||
//Backup table
|
||||
//db.CodeFirst.BackupTable().InitTables(typeof(CodeTable),typeof(CodeTable2));
|
||||
|
||||
//No backup table
|
||||
db.CodeFirst.InitTables(typeof(CodeTable),typeof(CodeTable2));
|
||||
db.CodeFirst.InitTables(typeof(GuidTable), typeof(CodeTable), typeof(CodeTable2));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -257,19 +257,19 @@ namespace SqlSugar
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName,bool isCache=true)
|
||||
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
|
||||
{
|
||||
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
|
||||
cacheKey = GetCacheKey(cacheKey);
|
||||
if (!isCache)
|
||||
return GetColumnInfosByTableName(tableName);
|
||||
else
|
||||
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
||||
() =>
|
||||
{
|
||||
return GetColumnInfosByTableName(tableName);
|
||||
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
||||
() =>
|
||||
{
|
||||
return GetColumnInfosByTableName(tableName);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
|
||||
@ -282,7 +282,7 @@ namespace SqlSugar
|
||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||
var schemaTable = reader.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
foreach (System.Data.DataRow row in schemaTable.Rows)
|
||||
{
|
||||
DbColumnInfo column = new DbColumnInfo()
|
||||
{
|
||||
@ -330,7 +330,7 @@ namespace SqlSugar
|
||||
string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME";
|
||||
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
||||
this.Context.Ado.IsEnableLogEvent = false;
|
||||
var pks = this.Context.Ado.SqlQuery<string>(sql,new { tableName=tableName.ToUpper() });
|
||||
var pks = this.Context.Ado.SqlQuery<string>(sql, new { tableName = tableName.ToUpper() });
|
||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||
return pks;
|
||||
});
|
||||
@ -350,7 +350,7 @@ namespace SqlSugar
|
||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||
return pks;
|
||||
});
|
||||
return comments.HasValue() ? comments.First(it=>it.DbColumnName.Equals(filedName,StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : "";
|
||||
return comments.HasValue() ? comments.First(it => it.DbColumnName.Equals(filedName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription : "";
|
||||
|
||||
}
|
||||
|
||||
@ -364,6 +364,10 @@ namespace SqlSugar
|
||||
{
|
||||
item.Length = 50;
|
||||
}
|
||||
if (item.DataType == "varchar" && item.Length == 0)
|
||||
{
|
||||
item.Length = 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
string sql = GetCreateTableSql(tableName, columns);
|
||||
|
Loading…
Reference in New Issue
Block a user