EntityContainer 클래스

정의

개념적 모델의 엔터티 컨테이너를 나타냅니다. EntityContainer는 엔터티 집합 및 연결 집합의 논리적 그룹입니다.

public ref class EntityContainer sealed : System::Data::Metadata::Edm::GlobalItem
public sealed class EntityContainer : System.Data.Metadata.Edm.GlobalItem
type EntityContainer = class
    inherit GlobalItem
Public NotInheritable Class EntityContainer
Inherits GlobalItem
상속
EntityContainer

예제

다음 코드 샘플에서는 연결에서 메타데이터 작업 영역을 가져와서 해당 메타데이터 작업 영역을 사용하여 지정된 데이터 모델의 엔터티 컨테이너에 대한 정보를 검색하는 방법을 보여 줍니다. 메타데이터 작업 영역은 메타데이터 검색을 지원하는 런타임 서비스 구성 요소입니다.

코드 샘플에서는 및 를 CSpaceSSpace 사용하여 모델을 지정합니다. CSpace는 개념적 모델의 기본 이름을 나타냅니다. SSpace는 스토리지 모델의 기본 이름을 나타냅니다.

메서드는 GetEntityContainers 엔터티 컨테이너의 컬렉션을 가져오고 컬렉션을 반복하여 지정된 컨테이너에서 각 엔터티 집합 및 연결 집합을 가져옵니다. 코드 샘플은 AdventureWorks 모델을 사용합니다.

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

class GetEntityContainerExample  
{  
  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=AdventureWorksEntities"))  
       {  
         // Open the connection.  
         connection.Open();  

         // Access the metadata workspace.  
         MetadataWorkspace workspace =   
            connection.GetMetadataWorkspace();  

         // Get the entity containers in the conceptual model.  
         GetEntityContainers(workspace, DataSpace.CSpace);  

         // Get the entity containers in the storage model.  
             GetEntityContainers(workspace, DataSpace.SSpace);  
       }  
    }  
    catch (MetadataException exceptionMetadata)  
    {  
      Console.WriteLine("MetadataException: {0}",   
                       exceptionMetadata.Message);  
    }  
    catch (System.Data.MappingException exceptionMapping)  
    {  
      Console.WriteLine("MappingException: {0}",  
                       exceptionMapping.Message);  
    }  
  }  

  public static void GetEntityContainers(  
      MetadataWorkspace workspace, DataSpace model)  
  {  
    // Get a collection of the entity containers.  
    ReadOnlyCollection<EntityContainer> containers =   
         workspace.GetItems<EntityContainer>(model);  

    // Iterate through the collection to get each entity container.  
    foreach (EntityContainer container in containers)  
    {  
       Console.WriteLine("EntityContainer Name: {0} ",   
                        container.Name);  

       // EntitySetBase is a super type for   
       // EntitySets and RelationshipSets.   
       // Iterate through the collection to get each EntitySetBase.  
       foreach (EntitySetBase baseSet in container.BaseEntitySets)  
       {  
          // Check if this instance is an EntitySet.  
          if (baseSet is EntitySet)  
          {  
             Console.WriteLine(  
                "  EntitySet Name: {0} , EntityType Name: {1} ",  
                baseSet.Name, baseSet.ElementType.FullName);  
          }  

         // RelationshipSet is a super type for AssociationSet.  
         // Check if this instance is an AssociationSet.  
         if (baseSet is AssociationSet)  
         {  
            Console.WriteLine(  
               "  AssociationSet Name: {0} , " +  
               "AssociationType Name: {1} ",  
                baseSet.Name, baseSet.ElementType.FullName);  

            // Get the AssociationSet.  
            AssociationSet associationSet =   
                  baseSet as AssociationSet;  

            // Iterate through the collection to get   
            // each AssociatedSetEnd.  
            foreach (AssociationSetEnd end in   
               associationSet.AssociationSetEnds)  
            {  
               Console.WriteLine(  
                  "   EntitySet Name: {0} , Name: {1} ",  
                  end.EntitySet, end.Name);  
            }  
         }  
      }  
    }  
  }  
}  
Imports System  
Imports System.Collections.ObjectModel  
Imports System.Data  
Imports System.Data.EntityClient  
Imports System.Data.Metadata.Edm  

Class GetEntityContainerExample  
  Public Shared Sub Main()  
    Try  
      ' 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 connection.  
        connection.Open()  

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

        ' Get the entity containers in the conceptual model.  
        GetEntityContainers(workspace, DataSpace.CSpace)  

        ' Get the entity containers in the storage model.  
        GetEntityContainers(workspace, DataSpace.SSpace)  
      End Using  
    Catch exceptionMetadata As MetadataException  
       Console.WriteLine("MetadataException: {0}", _  
          exceptionMetadata.Message)  
    Catch exceptionMapping As MappingException  
       Console.WriteLine("MappingException: {0}", _  
          exceptionMapping.Message)  
     End Try  
  End Sub  

  Public Shared Sub GetEntityContainers( _  
    ByVal workspace As MetadataWorkspace, ByVal model As DataSpace)  

    ' Get a collection of the entity containers.  
    Dim containers As ReadOnlyCollection(Of EntityContainer) = _  
       workspace.GetItems(Of EntityContainer)(model)  

    ' Iterate through the collection to get each entity container.  
    Dim container As EntityContainer  
    For Each container In containers  
      Console.WriteLine("EntityContainer Name: {0} ", container.Name)  

      ' EntitySetBase is a super type for   
      ' EntitySets and RelationshipSets.   
      ' Iterate through the collection to get each EntitySetBase.  
      Dim baseSet As EntitySetBase  
      For Each baseSet In container.BaseEntitySets  
         ' Check if this instance is an EntitySet.  
         If TypeOf baseSet Is EntitySet Then  
           Console.WriteLine( _  
              "  EntitySet Name: {0} , EntityType Name: {1} ", _  
              baseSet.Name, baseSet.ElementType.FullName)  
          End If  

          ' RelationshipSet is a super type for AssociationSet.  
          ' Check if this instance is an AssociationSet.  
          If TypeOf baseSet Is AssociationSet Then  
            Console.WriteLine( _  
              "  AssociationSet Name: {0} , " + _  
              "AssociationType Name: {1} ", _  
              baseSet.Name, baseSet.ElementType.FullName)  

            ' Get the AssociationSet.  
            Dim associationSet As AssociationSet = _  
               TryCast(baseSet, AssociationSet)  

            ' Iterate through the collection to get   
            '  each AssociatedSetEnd.  
            Dim endMember As AssociationSetEnd  
            For Each endMember In associationSet.AssociationSetEnds  
              Console.WriteLine( _  
                 "   EntitySet Name: {0} , Name: {1} ", _  
                 endMember.EntitySet, endMember.Name)  
            Next  
          End If  
      Next  
    Next  
  End Sub  
End Class  

설명

개념 수준에서 EntityContainer 클래스는 스토리지 메타데이터 스키마에서 데이터베이스 개체에 매핑되는 컨테이너를 나타냅니다. 스토리지의 측면에서 EntityContainer 클래스는 모델을 기반으로 빌드된 애플리케이션에서 데이터를 유지하는 테이블 및/또는 키 관계에 대한 설명을 나타냅니다. 개념적 모델의 엔터티 컨테이너에 대한 자세한 내용은 엔터티 컨테이너를 참조하세요.

속성

BaseEntitySets

EntityContainer에 포함된 엔터티 집합과 연결 집합의 목록을 가져옵니다.

BuiltInTypeKind

EntityContainer의 기본 제공 형식 유형을 가져옵니다.

Documentation

이 형식과 관련된 설명서를 가져오거나 설정합니다.

(다음에서 상속됨 MetadataItem)
FunctionImports

EdmFunction 요소의 컬렉션을 지정합니다. 각 함수에는 데이터베이스에 있는 저장 프로시저의 세부 정보 또는 엔터티 및 해당 속성에 매핑된 해당 CommandText 프로시저가 포함됩니다.

MetadataProperties

현재 형식의 속성 목록을 가져옵니다.

(다음에서 상속됨 MetadataItem)
Name

EntityContainer의 이름을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEntitySetByName(String, Boolean)

지정된 엔터티 집합 이름을 사용하여 EntitySet 개체를 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetRelationshipSetByName(String, Boolean)

지정된 관계 집합 이름을 사용하여 RelationshipSet 개체를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

EntityContainer의 이름을 반환합니다.

TryGetEntitySetByName(String, Boolean, EntitySet)

지정된 엔터티 집합 이름을 사용하여 EntitySet 개체를 반환합니다.

TryGetRelationshipSetByName(String, Boolean, RelationshipSet)

지정된 관계 집합 이름을 사용하여 RelationshipSet 개체를 반환합니다.

적용 대상