GlobalItem 類別

定義

表示所有概念模型類型和實體容器的基底項目類別。

public ref class GlobalItem abstract : System::Data::Metadata::Edm::MetadataItem
public abstract class GlobalItem : System.Data.Metadata.Edm.MetadataItem
type GlobalItem = class
    inherit MetadataItem
Public MustInherit Class GlobalItem
Inherits MetadataItem
繼承
GlobalItem
衍生

範例

下列程式碼範例會示範如何從連接中取得中繼資料工作空間,然後使用該中繼資料工作空間來瀏覽中繼資料型別階層架構。 請注意,中繼資料工作空間是一個執行階段服務元件,它會提供用來擷取中繼資料的支援。

此程式碼範例會使用 CSpace 來指定此模型。 CSpace 代表概念模型的預設名稱。 程式代碼範例會使用應用程式組態檔中提供的 連接字串。

using System;  
using System.Data;  
using System.Data.EntityClient;  
using System.Data.Metadata.Edm;  
using System.Collections.ObjectModel;  

class BrowseTypes  
{  
  static void Main()  
  {  
    try  
    {  
      // Establish a connection to the underlying data provider by  
      // using the connection string specified in the config file.  
      using (EntityConnection connection =  
             new EntityConnection("Name=AdventureworksContext"))  
      {  
         // Access the metadata workspace.  
         MetadataWorkspace workspace =   
              connection.GetMetadataWorkspace();  
         // Browse the metadata type hierarchy.  
         BrowseTypesExample(workspace);  
      }  
    }  
    catch (MetadataException exceptionMetadata)  
    {  
       Console.WriteLine("MetadataException: {0}",  
                         exceptionMetadata.Message);  
     }  
     catch (System.Data.MappingException exceptionMapping)  
     {  
        Console.WriteLine("MappingException: {0}",  
                          exceptionMapping.Message);  
     }  
  }  

  private static void BrowseTypesExample(MetadataWorkspace workspace)  
  {  
    // Get a collection of the GlobalItems.   
    // An GlobalItem class is the base class for   
    // the conceptual model types and entity containers.  
    ReadOnlyCollection<GlobalItem> items =   
         workspace.GetItems<GlobalItem>(DataSpace.CSpace);  

    // Iterate through the collection to get each item.  
    foreach (GlobalItem item in items)  
    {  
       Console.WriteLine(  
           "Item BuiltInTypeKind: {0}, Type: {1} ",   
           item.BuiltInTypeKind, item.GetType().FullName);  

       EntityContainer entityContainer = item as EntityContainer;  
       if (entityContainer != null)  
       {  
          Console.WriteLine(  
               "EntityContainer Name: {0}",  
               entityContainer.Name);  
          continue;  
       }  

       EntityType entityType = item as EntityType;  
       if (entityType != null)  
       {  
         Console.WriteLine(  
             "EntityType Name: {0}, Namespace: {1}",  
             entityType.Name, entityType.NamespaceName);  
        continue;  
       }  

       AssociationType associationType = item as AssociationType;  
       if (associationType != null)  
       {  
          Console.WriteLine(  
             "AssociationType Name: {0}, Namespace: {1}",  
             associationType.Name, associationType.NamespaceName);  
          continue;  
       }  

       PrimitiveType primType = item as PrimitiveType;  
       if (primType != null)  
       {  
         Console.WriteLine(  
             "PrimitiveType Name: {0}, Namespace: {1}",   
             primType.Name, primType.NamespaceName);  
         continue;  
       }  

       EdmFunction function = item as EdmFunction;  
       if (function != null)  
       {  
         Console.WriteLine(  
           "EdmFunction Name: {0}, Namespace: {1}",  
           function.Name, function.NamespaceName);  
         continue;  
       }  
    }  
  }  
}  

屬性

BuiltInTypeKind

取得這個型別的內建型別類型。

(繼承來源 MetadataItem)
Documentation

取得或設定與這個型別相關聯的文件。

(繼承來源 MetadataItem)
MetadataProperties

取得目前型別的屬性清單。

(繼承來源 MetadataItem)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於