mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-17 01:46:18 +08:00
Oracle CodeFirst BUG
This commit is contained in:
parent
62f34cd145
commit
58928e07be
@ -9,28 +9,35 @@ namespace OrmTest.Demo
|
|||||||
public class CodeTable
|
public class CodeTable
|
||||||
{
|
{
|
||||||
|
|
||||||
[SugarColumn(IsPrimaryKey =true)]
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[SugarColumn(Length = 21,OldColumnName = "Name2",ColumnDescription ="haha")]
|
[SugarColumn(Length = 21, OldColumnName = "Name2", ColumnDescription = "haha")]
|
||||||
public string Name{ get; set; }
|
public string Name { get; set; }
|
||||||
[SugarColumn(IsNullable = true,Length =10)]
|
[SugarColumn(IsNullable = true, Length = 10)]
|
||||||
public string IsOk { get; set; }
|
public string IsOk { get; set; }
|
||||||
public Guid Guid { get; set; }
|
public Guid Guid { get; set; }
|
||||||
[SugarColumn(ColumnDataType ="int")]
|
[SugarColumn(ColumnDataType = "int")]
|
||||||
public decimal Decimal { get; set; }
|
public decimal Decimal { get; set; }
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public DateTime? DateTime { get; set; }
|
public DateTime? DateTime { get; set; }
|
||||||
[SugarColumn(IsNullable = true,OldColumnName = "Dob")]
|
[SugarColumn(IsNullable = true, OldColumnName = "Dob")]
|
||||||
public double? Dob2 { get; set; }
|
public double? Dob2 { get; set; }
|
||||||
[SugarColumn(Length =110)]
|
[SugarColumn(Length = 110)]
|
||||||
public string A2{ get; set; }
|
public string A2 { get; set; }
|
||||||
}
|
}
|
||||||
public class CodeTable2 {
|
public class CodeTable2
|
||||||
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[SugarColumn(IsIgnore =true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public string TestId { get; set; }
|
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 class CodeFirst : DemoBase
|
||||||
{
|
{
|
||||||
public static void Init()
|
public static void Init()
|
||||||
@ -47,7 +54,8 @@ namespace OrmTest.Demo
|
|||||||
//db.CodeFirst.BackupTable().InitTables(typeof(CodeTable),typeof(CodeTable2));
|
//db.CodeFirst.BackupTable().InitTables(typeof(CodeTable),typeof(CodeTable2));
|
||||||
|
|
||||||
//No backup table
|
//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;
|
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();
|
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
|
||||||
cacheKey = GetCacheKey(cacheKey);
|
cacheKey = GetCacheKey(cacheKey);
|
||||||
if (!isCache)
|
if (!isCache)
|
||||||
return GetColumnInfosByTableName(tableName);
|
return GetColumnInfosByTableName(tableName);
|
||||||
else
|
else
|
||||||
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
return GetColumnInfosByTableName(tableName);
|
return GetColumnInfosByTableName(tableName);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
|
private List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
|
||||||
@ -282,7 +282,7 @@ namespace SqlSugar
|
|||||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||||
var schemaTable = reader.GetSchemaTable();
|
var schemaTable = reader.GetSchemaTable();
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
foreach (System.Data.DataRow row in schemaTable.Rows)
|
||||||
{
|
{
|
||||||
DbColumnInfo column = new DbColumnInfo()
|
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";
|
string sql = "SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME =@tableName ORDER BY TABLE_NAME";
|
||||||
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
||||||
this.Context.Ado.IsEnableLogEvent = false;
|
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;
|
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||||
return pks;
|
return pks;
|
||||||
});
|
});
|
||||||
@ -350,7 +350,7 @@ namespace SqlSugar
|
|||||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||||
return pks;
|
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;
|
item.Length = 50;
|
||||||
}
|
}
|
||||||
|
if (item.DataType == "varchar" && item.Length == 0)
|
||||||
|
{
|
||||||
|
item.Length = 50;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string sql = GetCreateTableSql(tableName, columns);
|
string sql = GetCreateTableSql(tableName, columns);
|
||||||
|
Loading…
Reference in New Issue
Block a user