ComplexType Classe

Definição

Representa um tipo complexo em um modelo conceitual.Represents a complex type in a conceptual model.

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
Herança

Exemplos

O exemplo de código a seguir obtém um espaço de trabalho de metadados da conexão e usa esse espaço de trabalho de metadados para recuperar informações sobre as propriedades dos tipos complexos no modelo especificado.The following code sample gets a metadata workspace from the connection and uses that metadata workspace to retrieve information about the properties of the complex types in the specified model. Observe que o espaço de trabalho de metadados é um componente de serviço de tempo de execução que fornece suporte para a recuperação de metadados.Note that the metadata workspace is a runtime service component that provides support for retrieving metadata.

O exemplo de código usa um CSpace para especificar o modelo.The code sample uses a CSpace to specify the model. O CSpace representa o nome padrão do modelo conceitual.The CSpace represents the default name for the conceptual model. O exemplo de código usa o modelo CustomerComplexAddr que é fornecido em como definir um modelo com um tópico de tipos complexos (Entity Framework) .The code sample uses the CustomerComplexAddr model that is provided in How to: Define a Model with Complex Types (Entity Framework) topic.

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  

Comentários

O ComplexType em um modelo conceitual representa um tipo que inclui um conjunto de propriedades como um tipo de entidade, mas não inclui uma propriedade de chave.The ComplexType in a conceptual model represents a type that includes a set of properties like an entity type but does not include a key property. Para obter mais informações sobre os tipos complexos em um modelo conceitual, consulte tipo complexo e como: definir um modelo com tipos complexos (Entity Framework).For more information about the complex types in a conceptual model, see Complex Type and How to: Define a Model with Complex Types (Entity Framework).

Propriedades

Abstract

Obtém um valor que indica se este tipo é abstrato ou não.Gets a value indicating whether this type is abstract or not.

(Herdado de EdmType)
BaseType

Obtém o tipo base deste link.Gets the base type of this type.

(Herdado de EdmType)
BuiltInTypeKind

Obtém a variante do tipo interno para este ComplexType.Gets the built-in type kind for this ComplexType.

Documentation

Obtém ou define a documentação associada a esse tipo.Gets or sets the documentation associated with this type.

(Herdado de MetadataItem)
FullName

Obtém o nome completo desse tipo.Gets the full name of this type.

(Herdado de EdmType)
Members

Obtém a lista de membros neste tipo.Gets the list of members on this type.

(Herdado de StructuralType)
MetadataProperties

Obtém a lista de propriedades do tipo atual.Gets the list of properties of the current type.

(Herdado de MetadataItem)
Name

Obtém o nome deste tipo.Gets the name of this type.

(Herdado de EdmType)
NamespaceName

Obtém o namespace desse tipo.Gets the namespace of this type.

(Herdado de EdmType)
Properties

Obtém a lista de propriedades para este ComplexType.Gets the list of properties for this ComplexType.

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetCollectionType()

Retorna uma instância do CollectionType, cujo tipo de elemento é esse tipo.Returns an instance of the CollectionType whose element type is this type.

(Herdado de EdmType)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToString()

Retorna o nome completo desse tipo.Returns the full name of this type.

(Herdado de EdmType)

Aplica-se a