SMO - 程序集依赖关系

发布于 2024-08-06 19:02:19 字数 61 浏览 3 评论 0原文

我需要使用 SMO 找出已注册程序集 (SQLCLR) 的所有依赖项。 我怎样才能做到这一点? 谢谢,内斯特

I need to use SMO to find out all the dependencies of a registered assembly (SQLCLR).
How can I do that?
Thanks, Nestor

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖心男生 2024-08-13 19:02:19

事实上,这里有一个更好的答案:

static public List<Urn> GetDependencies(SqlAssembly assembly)
{
    return GetDependencies(assembly.Parent.Parent, assembly.Urn);
}
static public List<Urn> GetDependencies(Server server, Urn obj)
{
    Scripter scr = new Scripter(server);
    DependencyTree tree = scr.DiscoverDependencies(new Urn[] { obj }, DependencyType.Parents);
    DependencyWalker depwalker = new DependencyWalker();
    DependencyCollection depcoll = depwalker.WalkDependencies(tree);
    List<Urn> dependencies = new List<Urn>();
    foreach (DependencyCollectionNode dep in depcoll) dependencies.Add(dep.Urn);
    return dependencies;
}

Actually, here is a better answer:

static public List<Urn> GetDependencies(SqlAssembly assembly)
{
    return GetDependencies(assembly.Parent.Parent, assembly.Urn);
}
static public List<Urn> GetDependencies(Server server, Urn obj)
{
    Scripter scr = new Scripter(server);
    DependencyTree tree = scr.DiscoverDependencies(new Urn[] { obj }, DependencyType.Parents);
    DependencyWalker depwalker = new DependencyWalker();
    DependencyCollection depcoll = depwalker.WalkDependencies(tree);
    List<Urn> dependencies = new List<Urn>();
    foreach (DependencyCollectionNode dep in depcoll) dependencies.Add(dep.Urn);
    return dependencies;
}
我的痛♀有谁懂 2024-08-13 19:02:19

我想我可以使用 TSQL 查询它:

select 
   a.name as 'assembly', 
   (select name from sys.assemblies where assembly_id = r.referenced_assembly_id) as 'referenced_assembly'
from sys.assemblies a left outer join sys.assembly_references r on (a.assembly_id=r.assembly_id)
where a.is_user_defined = 1
order by assembly

:-)

I guess I can query it using TSQL:

select 
   a.name as 'assembly', 
   (select name from sys.assemblies where assembly_id = r.referenced_assembly_id) as 'referenced_assembly'
from sys.assemblies a left outer join sys.assembly_references r on (a.assembly_id=r.assembly_id)
where a.is_user_defined = 1
order by assembly

:-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文