Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取ViewColumn的BaseColumn_C#_Sql Server_Sql Server 2008_C# 4.0_Metadata - Fatal编程技术网

C# 获取ViewColumn的BaseColumn

C# 获取ViewColumn的BaseColumn,c#,sql-server,sql-server-2008,c#-4.0,metadata,C#,Sql Server,Sql Server 2008,C# 4.0,Metadata,假设这一观点: SELECT [Pr].[Id], [Pr].[Title], [Pr].[Category_Id] AS [CategoryId], [Pr].[IsScanAllowed], [Pr].[MaxLevelOfRegistration], [Cat].[Title] AS [Category], [Cat].[MajorCategory_Id] AS [MajorCategoryId], [Mc].[Title] AS [MajorCategory] [Cat

假设这一观点:

SELECT
 [Pr].[Id],
 [Pr].[Title],
 [Pr].[Category_Id] AS [CategoryId],
 [Pr].[IsScanAllowed],
 [Pr].[MaxLevelOfRegistration],
 [Cat].[Title] AS [Category],
 [Cat].[MajorCategory_Id] AS [MajorCategoryId],
 [Mc].[Title] AS [MajorCategory]
 [Cat].[Title]+[Pr].[Title] AS [FullProduct]
FROM [Products].[Product] AS [Pr]
INNER JOIN [Products].[Category] AS [Cat] ON [Pr].[Category_Id] = [Cat].[Id]
INNER JOIN [Products].[MajorCategory] AS [Mc] ON [Cat].[MajorCategory_Id] = [Mc].[Id];

因此,除了作为计算列的
[FullProduct]
之外,是否有任何方法可以找到此视图中每个列的基列?所有其他列都有一个基列。类似于这样:
BaseOf(MajorCategoryId)是[Products].[MajorCategory].[Id]
我尝试使用
Microsoft.SqlServer.Management.Smo
但我找不到任何东西,有人知道吗?

因为它没有传回客户端,但您可以构造列名来显示它——如下所示:

SELECT
 [Pr].[Id] AS [Products_Id],
 [Pr].[Title] AS [Products_Title],
 [Pr].[Category_Id] AS [Products_CategoryId],
 [Pr].[IsScanAllowed] AS [Products_IsScanAllowed],
 [Pr].[MaxLevelOfRegistration] [Products_MaxLevelOfRegistration],
 [Cat].[Title] AS [Category_Title],
 [Cat].[MajorCategory_Id] AS [Category_MajorCategoryId],
 [Mc].[Title] AS [MajorCategory_Title]
 [Cat].[Title]+[Pr].[Title] AS [FullProduct]
FROM [Products].[Product] AS [Pr]
INNER JOIN [Products].[Category] AS [Cat] ON [Pr].[Category_Id] = [Cat].[Id]
INNER JOIN [Products].[MajorCategory] AS [Mc] ON [Cat].[MajorCategory_Id] = [Mc].[Id];
然后,要查看该表,您可以在
上获取拆分中的第一项



您还可以使用SQL元数据下载视图的源代码,并对其进行解析,但这对我来说似乎是一项艰巨的工作。

由于它没有传回客户端,因此无法知道这一点,但您可以构造列名来显示它——如下所示:

SELECT
 [Pr].[Id] AS [Products_Id],
 [Pr].[Title] AS [Products_Title],
 [Pr].[Category_Id] AS [Products_CategoryId],
 [Pr].[IsScanAllowed] AS [Products_IsScanAllowed],
 [Pr].[MaxLevelOfRegistration] [Products_MaxLevelOfRegistration],
 [Cat].[Title] AS [Category_Title],
 [Cat].[MajorCategory_Id] AS [Category_MajorCategoryId],
 [Mc].[Title] AS [MajorCategory_Title]
 [Cat].[Title]+[Pr].[Title] AS [FullProduct]
FROM [Products].[Product] AS [Pr]
INNER JOIN [Products].[Category] AS [Cat] ON [Pr].[Category_Id] = [Cat].[Id]
INNER JOIN [Products].[MajorCategory] AS [Mc] ON [Cat].[MajorCategory_Id] = [Mc].[Id];
然后,要查看该表,您可以在
上获取拆分中的第一项


您还可以使用SQL元数据下载视图的源代码,并对其进行解析,但这对我来说似乎是一项艰巨的工作