ComplexType ComplexType ComplexType ComplexType Class

Definizione

Rappresenta un tipo complesso in un modello concettuale.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
Ereditarietà

Esempi

Esempio di codice seguente ottiene un'area di lavoro metadati dalla connessione e utilizza tale area di lavoro dei metadati per recuperare informazioni sulle proprietà dei tipi complessi nel modello specificato.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. Si noti che l'area di lavoro metadati è un componente del servizio di runtime che fornisce supporto per il recupero dei metadati.Note that the metadata workspace is a runtime service component that provides support for retrieving metadata.

Nell'esempio di codice viene utilizzato un oggetto CSpace per specificare il modello.The code sample uses a CSpace to specify the model. CSpace rappresenta il nome predefinito per il modello concettuale.The CSpace represents the default name for the conceptual model. Nell'esempio di codice Usa il modello CustomerComplexAddr incluso nel come: Definire un modello con i tipi complessi (Entity Framework) argomento.The code sample uses the CustomerComplexAddr model that is provided in How to: Define a Model with Complex Types (Entity Framework) topic. Per un esempio di file di configurazione dell'applicazione, vedere implementazione complesso tipo (EDM) argomento.For an example of the application config file, see Implementing Complex Type (EDM) 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  

Commenti

Il ComplexType in un modello concettuale rappresenta un tipo che include un set di proprietà come un tipo di entità ma non include una proprietà chiave.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. Per altre informazioni sui tipi complessi in un modello concettuale, vedere tipo complesso e come: Definire un modello con i tipi complessi (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).

Proprietà

Abstract Abstract Abstract Abstract

Ottiene un valore che indica se il tipo è o non è astratto.Gets a value indicating whether this type is abstract or not.

(Inherited from EdmType)
BaseType BaseType BaseType BaseType

Ottiene il tipo di base del tipo.Gets the base type of this type.

(Inherited from EdmType)
BuiltInTypeKind BuiltInTypeKind BuiltInTypeKind BuiltInTypeKind

Ottiene il tipo del tipo incorporato per ComplexType.Gets the built-in type kind for this ComplexType.

Documentation Documentation Documentation Documentation

Ottiene o imposta la documentazione associata al tipo.Gets or sets the documentation associated with this type.

(Inherited from MetadataItem)
FullName FullName FullName FullName

Ottiene il nome completo del tipo.Gets the full name of this type.

(Inherited from EdmType)
Members Members Members Members

Ottiene l'elenco di membri nel tipo.Gets the list of members on this type.

(Inherited from StructuralType)
MetadataProperties MetadataProperties MetadataProperties MetadataProperties

Ottiene l'elenco di proprietà del tipo corrente.Gets the list of properties of the current type.

(Inherited from MetadataItem)
Name Name Name Name

Ottiene il nome del tipo.Gets the name of this type.

(Inherited from EdmType)
NamespaceName NamespaceName NamespaceName NamespaceName

Ottiene lo spazio dei nomi del tipo.Gets the namespace of this type.

(Inherited from EdmType)
Properties Properties Properties Properties

Ottiene l'elenco di proprietà per l'oggetto ComplexType.Gets the list of properties for this ComplexType.

Metodi

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetCollectionType() GetCollectionType() GetCollectionType() GetCollectionType()

Restituisce un'istanza di CollectionType il cui tipo di elemento è il tipo corrente.Returns an instance of the CollectionType whose element type is this type.

(Inherited from EdmType)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Restituisce il nome completo del tipo.Returns the full name of this type.

(Inherited from EdmType)

Si applica a