ComplexType Klasse

Definition

Stellt einen komplexen Typ in einem konzeptionellen Modell dar.

public ref class ComplexType : System::Data::Metadata::Edm::StructuralType
public class ComplexType : System.Data.Metadata.Edm.StructuralType
type ComplexType = class
    inherit StructuralType
Public Class ComplexType
Inherits StructuralType
Vererbung

Beispiele

Im folgenden Codebeispiel wird ein Metadatenarbeitsbereich aus der Verbindung abgerufen und dieser Metadatenarbeitsbereich verwendet, um Informationen zu den Eigenschaften der komplexen Typen im angegebenen Modell abzurufen. Beachten Sie, dass es sich beim Metadaten-Arbeitsbereich um eine Laufzeitdienstkomponente handelt, die Unterstützung für das Abrufen von Metadaten bereitstellt.

Im Codebeispiel wird CSpace verwendet, um das Modell anzugeben. CSpace stellt den Standardnamen für das konzeptionelle Modell dar. Im Codebeispiel wird das CustomerComplexAddr-Modell verwendet, das im Thema Vorgehensweise: Definieren eines Modells mit komplexen Typen (Entity Framework) bereitgestellt wird.

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

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

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

         // Get properties of complex types.  
         GetProperties(workspace, DataSpace.CSpace);  
      }  
    }  
    catch (MetadataException exceptionMetadata)  
    {  
       Console.WriteLine("MetadataException: {0}",  
              exceptionMetadata.Message);  
    }  
    catch (System.Data.MappingException exceptionMapping)  
    {  
       Console.WriteLine("MappingException: {0}",  
               exceptionMapping.Message);  
    }  
  }  

  public static void GetProperties(MetadataWorkspace workspace,   
      DataSpace model)  
  {  
    // Get a collection of complex types.  
    ReadOnlyCollection<ComplexType> complexTypes =  
       workspace.GetItems<ComplexType>(model);  

    // Iterate through the collection to get each complex type.  
    foreach (ComplexType complexType in complexTypes)  
    {  
       Console.WriteLine(  
         "\n\n***ComplexType Name: {0}, Namespace: {1}",  
         complexType.Name,  
         complexType.NamespaceName);  

       Console.WriteLine(  
          "\nGet the properties of this " +  
          "ComplexType object ==>");  
          // Iterate through the collection to get each property of the   
          // current ComplexType object.  
          foreach (EdmProperty property in complexType.Properties)  
          {  
            Console.Write("   Property Name: {0} ", property.Name);  

            Console.WriteLine(  
               "   Property declaring Type: {0}, edmtype: {1}," +  
               " default: {2}, nullable: {3} ",  
               property.DeclaringType, property.TypeUsage.EdmType,  
               property.Default, property.Nullable);  
          }  
      }  
  }  
}  
Imports System  
Imports System.Collections.ObjectModel  
Imports System.Data  
Imports System.Data.EntityClient  
Imports System.Data.Metadata.Edm  

Class GetComplexTypeMembersExample  
  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=CustomerWComplexAddrEntities")  

         ' Open the connection.  
         connection.Open()  

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

         ' Get properties of complex types.  
         GetProperties(workspace, DataSpace.CSpace)  
      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 GetProperties( _  
    ByVal workspace As MetadataWorkspace, ByVal model As DataSpace)  

    ' Get a collection of complex types.  
    Dim complexTypes As ReadOnlyCollection(Of ComplexType) = _  
       workspace.GetItems(Of ComplexType)(model)  

    ' Iterate through the collection to get each complex type.  
    Dim complexType As ComplexType  
    For Each complexType In complexTypes  
       Console.WriteLine( _  
          ControlChars.Lf & ControlChars.Lf & _  
          "***ComplexType Name: {0}, Namespace: {1}", _  
          complexType.Name, complexType.NamespaceName)  

       Console.WriteLine(ControlChars.Lf & _  
          "Get the properties of this ComplexType object ==>")  

          ' Iterate through the collection to get each property of the   
          ' current ComplexType object.  
          Dim property1 As EdmProperty  
          For Each property1 In complexType.Properties  
            Console.Write("   Property Name: {0} ", property1.Name)  
            Console.WriteLine( _  
              "   Property declaring Type: {0}, edmtype: {1}, " + _  
              "default: {2}, nullable: {3} ", _  
              New Object() {property1.DeclaringType, _  
              property1.TypeUsage.EdmType, _  
              property1.Default, property1.Nullable})  
          Next  
        Next  
    End Sub  
End Class  

Hinweise

Der ComplexType in einem konzeptionellen Modell stellt einen Typ dar, der einen Satz von Eigenschaften wie einen Entitätstyp enthält, aber keine Schlüsseleigenschaft enthält. Weitere Informationen zu den komplexen Typen in einem konzeptionellen Modell finden Sie unter Komplexer Typ und Vorgehensweise: Definieren eines Modells mit komplexen Typen (Entity Framework).

Eigenschaften

Abstract

Ruft einen Wert ab, der angibt, ob es sich um einen abstrakten Typ handelt oder nicht.

(Geerbt von EdmType)
BaseType

Ruft den Basistyp dieses Typs ab.

(Geerbt von EdmType)
BuiltInTypeKind

Ruft die integrierte Typart für ComplexType auf.

Documentation

Ruft die diesem Typ zugeordnete Dokumentation ab bzw. legt sie fest.

(Geerbt von MetadataItem)
FullName

Ruft den vollständigen Namen dieses Typs ab.

(Geerbt von EdmType)
Members

Ruft eine Liste der Member dieses Typs ab.

(Geerbt von StructuralType)
MetadataProperties

Ruft eine Liste der Eigenschaften des aktuellen Typs ab.

(Geerbt von MetadataItem)
Name

Ruft den Namen dieses Typs ab.

(Geerbt von EdmType)
NamespaceName

Ruft den Namespace dieses Typs ab.

(Geerbt von EdmType)
Properties

Ruft die Liste der Eigenschaften für diesen ComplexType ab.

Methoden

Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetCollectionType()

Gibt eine Instanz des CollectionType zurück, dessen Elementtyp diesem Typ entspricht.

(Geerbt von EdmType)
GetHashCode()

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()

Gibt den vollständigen Namen dieses Typs zurück.

(Geerbt von EdmType)

Gilt für: