Export (0) Print
Expand All

GlobalItem Class

Represents the base item class for all the conceptual model types and entity containers.

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

public abstract class GlobalItem : MetadataItem

The GlobalItem type exposes the following members.

  NameDescription
Public propertyBuiltInTypeKindGets the built-in type kind for this type. (Inherited from MetadataItem.)
Public propertyDocumentationGets or sets the documentation associated with this type. (Inherited from MetadataItem.)
Public propertyMetadataPropertiesGets the list of properties of the current type. (Inherited from MetadataItem.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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 to specify the model. The CSpace represents the default name for the conceptual model. The code sample uses the connection string that is provided in the application config file. For an example of the application config file, see Adventure Works Object Model in Applications (EDM).

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;
       }
    }
  }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

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