.NET Framework Class Library GlobalItem Class Represents the base item class for all the conceptual model types and entity containers.

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

Syntax
Public MustInherit Class GlobalItem _
Inherits MetadataItem
public abstract class GlobalItem : MetadataItem
public ref class GlobalItem abstract : public MetadataItem
[<AbstractClass>]
type GlobalItem =
class
inherit MetadataItem
end
The GlobalItem type exposes the following members.

Properties

Methods

Remarks

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

Version Information
.NET FrameworkSupported in: 4, 3.5 SP1 .NET Framework Client ProfileSupported in: 4

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

See Also
|
.NET Framework 클래스 라이브러리 GlobalItem 클래스 모든 개념적 모델 형식과 엔터티 컨테이너의 기본 항목 클래스를 나타냅니다.

상속 계층 구조
네임스페이스:
System.Data.Metadata.Edm
어셈블리:
System.Data.Entity(System.Data.Entity.dll)

구문
Public MustInherit Class GlobalItem _
Inherits MetadataItem
public abstract class GlobalItem : MetadataItem
public ref class GlobalItem abstract : public MetadataItem
[<AbstractClass>]
type GlobalItem =
class
inherit MetadataItem
end
GlobalItem 형식에서는 다음과 같은 멤버를 노출합니다.

속성

메서드

설명

예제
다음 코드 샘플에서는 연결에서 메타데이터 작업 영역을 가져온 다음 이 메타데이터 작업 영역을 사용하여 메타데이터 형식 계층 구조를 탐색하는 방법을 보여 줍니다. 메타데이터 작업 영역은 메타데이터 검색을 지원하는 런타임 서비스 구성 요소입니다. 이 코드 예제에서는 CSpace를 사용하여 모델을 지정합니다. CSpace는 개념적 모델의 기본 이름을 나타냅니다. 코드 샘플에서는 응용 프로그램 구성 파일에서 제공되는 연결 문자열을 사용합니다. 응용 프로그램 구성 파일의 예제를 보려면 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 Framework4, 3.5 SP1에서 지원 .NET Framework Client Profile4에서 지원

플랫폼
Windows 7, Windows Vista SP1 이상, Windows XP SP3, Windows Server 2008(Server Core는 지원되지 않음), Windows Server 2008 R2(Server Core는 SP1 이상에서 지원됨), Windows Server 2003 SP2
.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

스레드로부터의 안전성
이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목
|