SSDT 프로젝트에서 DacFx API를 사용하여 데이터베이스의 메모리 모델을 쿼리하고 있습니다. Column의 Type을 검색하려고 시도했지만 알아낼 수는 없습니다. 이것이 어떻게 이루어질 수 있었는지 아는 어떤 생각?DacFx API를 사용하여 열의 유형을 얻는 방법은 무엇입니까?
private void TestMethod()
{
using(TSqlModel model =
new TSqlModel(SqlServerVersion.Sql110, new TSqlModelOptions {}))
{
string[] scripts = new[]
{
"CREATE TABLE t1 (c1 NVARCHAR(30) NOT NULL)",
"CREATE TABLE t2 (c2 INT NOT NULL)"
};
foreach (string script in scripts)
{
model.AddObjects(script);
}
var tables = model.GetObjects(DacQueryScopes.All, Table.TypeClass);
var cols = tables.First().GetReferenced(Table.Columns);
foreach (TSqlObject col in cols)
{
//?? how can I get the data type of the column?
string dataType = col.??;
if (dataType == "int")
{
//my thing here
}
}
}
}
나중에 나 자신과 다른 사람들을 위해 column이 사용자 정의 데이터 유형 인 경우 datatypeName은 인덱스 1, 즉 Name.Parts [1]에 있습니다. – NoSaidTheCompiler