This documentation is archived and is not being maintained.

GlobalItem Class

Represents the base item class for all the Entity Data Model (EDM) types and the entity containers.

Namespace:  System.Data.Metadata.Edm
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

Public MustInherit Class GlobalItem _
	Inherits MetadataItem
Dim instance As GlobalItem

For more information, see Metadata Type Hierarchy Overview.

The following code sample demonstrates how to get a metadata workspace from the connection and then use that metadata workspace to browse the metadata type hierarchy. Note that the metadata workspace is a runtime service component that provides support for retrieving metadata.

The code sample uses a CSpace and a SSpace to specify the model. The CSpace represents the default name for the conceptual model. The SSpace represents the default name for the storage model. The code sample uses the AdventureWorks model that is provided in the Adventure Works Model (EDM) topic. For an example of the application config file, see Adventure Works Object Model in Applications (EDM).

Imports System
Imports System.Collections.ObjectModel
Imports System.Data
Imports System.Data.EntityClient
Imports System.Data.Metadata.Edm

Class BrowseTypes
  Public Shared Sub Main()
      ' Establish a connection to the underlying data provider by 
      ' using the connection string specified in the config file.
      Using connection As EntityConnection = _
         New EntityConnection("Name=AdventureWorksEntities")

        ' Open the conection.

        ' Access the metadata workspace.
        Dim workspace As MetadataWorkspace = _

        ' Browse the metadata type hierarchy in the conceptual model.
        BrowseTypesExample(workspace, DataSpace.CSpace)

        ' Browse the metadata type hierarchy in the storage model.
        BrowseTypesExample(workspace, DataSpace.SSpace)
      End Using
    Catch exceptionMetadata As MetadataException
      Console.WriteLine("MetadataException: {0}", _
    Catch exceptionMapping As MappingException
      Console.WriteLine("MappingException: {0}", _
    End Try
  End Sub

  Public Shared Sub BrowseTypesExample( _
        ByVal workspace As MetadataWorkspace, _
        ByVal model As DataSpace)
    ' Get a collection of the GlobalItems. 
    ' An GlobalItem class is the base class for 
    ' the entity data model types and entity containers.
    Dim items As ReadOnlyCollection(Of GlobalItem) = _
      workspace.GetItems(Of GlobalItem)(model)

    ' Iterate through the collection to get each item.
    Dim item As GlobalItem
    For Each item In items
     Dim entityContainer As EntityContainer = _
          TryCast(item, EntityContainer)
     If (Not entityContainer Is Nothing) Then
       Console.WriteLine("EntityContainer Name: {0}", _
       Continue For
     End If

     Dim entityType As EntityType = TryCast(item, EntityType)
     If (Not entityType Is Nothing) Then
       Console.WriteLine("EntityType Name: {0}, Namespace: {1}", _
                entityType.Name, entityType.NamespaceName)
       Continue For
     End If

     Dim associationType As AssociationType = _
            TryCast(item, AssociationType)
     If (Not associationType Is Nothing) Then
       Console.WriteLine("AssociationType Name: {0}, Namespace: {1}", _
              associationType.Name, associationType.NamespaceName)
       Continue For
     End If

     Dim primType As PrimitiveType = TryCast(item, PrimitiveType)
     If (Not primType Is Nothing) Then
       Console.WriteLine("PrimitiveType Name: {0}, Namespace: {1}", _
               primType.Name, primType.NamespaceName)
       Continue For
      End If

      Dim functionEdm As EdmFunction = TryCast(item, EdmFunction)
        If (Not functionEdm Is Nothing) Then
          Console.WriteLine("EdmFunction Name: {0}, Namespace: {1}", _
               functionEdm.Name, functionEdm.NamespaceName)
          Continue For
        End If
  End Sub
End Class

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1