- 增加 ZeroDbContext.LoadTableDescriptor 方法从数据库中加载描述对象;

This commit is contained in:
2881099
2025-04-18 14:02:48 +08:00
parent e63f23add7
commit 8627f6277b
9 changed files with 116 additions and 12 deletions

View File

@@ -290,6 +290,8 @@ where {1}
,a.is_identity 'isidentity'
,f.text as 'defaultvalue'
,a.column_id as 'position'
,a.precision
,a.scale
from sys.columns", loc8.ToString().Replace("a.table_name", "a.object_id"), @"
left join syscomments f on f.id = a.default_object_id
");
@@ -303,6 +305,8 @@ left join syscomments f on f.id = a.default_object_id
,a.is_output 'isidentity'
,'' as 'defaultvalue'
,1 as 'position'
,a.precision
,a.scale
from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"), "");
}
sql = $"use [{db}];{sql};use [{olddatabase}]; ";
@@ -323,6 +327,8 @@ from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"), "
var defaultValue = string.Concat(row[9]);
var position = int.Parse(string.Concat(row[10]));
if (max_length == 0) max_length = -1;
int.TryParse(string.Concat(row[11]), out var numeric_precision);
int.TryParse(string.Concat(row[12]), out var numeric_scale);
loc3[object_id].Add(column, new DbColumnInfo
{
@@ -336,7 +342,9 @@ from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"), "
Table = loc2[object_id],
Comment = comment,
DefaultValue = defaultValue,
Position = position
Position = position,
Precision = numeric_precision,
Scale = numeric_scale,
});
loc3[object_id][column].DbType = this.GetDbType(loc3[object_id][column]);
loc3[object_id][column].CsType = this.GetCsTypeInfo(loc3[object_id][column]);