ComplexType Class

Represents a complex type in a conceptual model.

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

Public Class ComplexType _
	Inherits StructuralType

The ComplexType type exposes the following members.

Public propertyAbstractGets a value indicating whether this type is abstract or not. (Inherited from EdmType.)
Public propertyBaseTypeGets the base type of this type. (Inherited from EdmType.)
Public propertyBuiltInTypeKindGets the built-in type kind for this ComplexType. (Overrides MetadataItem.BuiltInTypeKind.)
Public propertyDocumentationGets or sets the documentation associated with this type. (Inherited from MetadataItem.)
Public propertyFullNameGets the full name of this type. (Inherited from EdmType.)
Public propertyMembersGets the list of members on this type. (Inherited from StructuralType.)
Public propertyMetadataPropertiesGets the list of properties of the current type. (Inherited from MetadataItem.)
Public propertyNameGets the name of this type. (Inherited from EdmType.)
Public propertyNamespaceNameGets the namespace of this type. (Inherited from EdmType.)
Public propertyPropertiesGets the list of properties for this ComplexType.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetCollectionTypeReturns an instance of the CollectionType whose element type is this type. (Inherited from EdmType.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns the full name of this type. (Inherited from EdmType.)

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. 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).

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. 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 CustomerComplexAddr model that is provided in How to: Define a Model with Complex Types (Entity Framework) topic. For an example of the application config file, see Implementing Complex Type (EDM) topic.

Imports System
Imports System.Collections.ObjectModel
Imports System.Data
Imports System.Data.EntityClient
Imports System.Data.Metadata.Edm

Class GetComplexTypeMembersExample
  Public Shared Sub Main()
      ' 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 conection.

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

         ' Get properties of complex types.
         GetProperties(workspace, DataSpace.CSpace)
      End Using
    Catch exceptionMetadata As MetadataException
       Console.WriteLine("MetadataException: {0}", _
    Catch exceptionMapping As MappingException
       Console.WriteLine("MappingException: {0}", _
     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})
    End Sub
End Class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft