MetadataTools

Responsible for making the Entity Framework Metadata more accessible for code generation.

Syntax

public static class MetadataTools

Inheritance

Methods

ClrType

public static Type ClrType(TypeUsage typeUsage)
This method returns the underlying CLR type of the o-space type corresponding to the supplied typeUsage Note that for an enum type this means that the type backing the enum will be returned, not the enum type itself.

Parameters

Returns

Type

Comment

public static string Comment(EdmProperty edmProperty)

Parameters

Returns

string

Comment

public static string Comment(EdmType edmType)

Parameters

Returns

string

Comment

public static string Comment(EntityContainer container)

Parameters

Returns

string

Comment

public static string Comment(EntitySet entitySet)

Parameters

Returns

string

Comment

public static string Comment(NavigationProperty navigationProperty)

Parameters

Returns

string

GetCorrespondingDependentProperty

public static EdmProperty GetCorrespondingDependentProperty(NavigationProperty navProperty, EdmProperty principalProperty)
Given a property on the principal end of a referential constraint, returns the corresponding property on the dependent end. Requires: The association has a referential constraint, and the specified principalProperty is one of the properties on the principal end.

Parameters

Returns

EdmProperty

GetCorrespondingPrincipalProperty

public static EdmProperty GetCorrespondingPrincipalProperty(NavigationProperty navProperty, EdmProperty dependentProperty)
Given a property on the dependent end of a referential constraint, returns the corresponding property on the principal end. Requires: The association has a referential constraint, and the specified dependentProperty is one of the properties on the dependent end.

Parameters

Returns

EdmProperty

GetDependentProperties

public static ReadOnlyMetadataCollection<EdmProperty> GetDependentProperties(NavigationProperty navProperty)
Gets the collection of properties that are on the dependent end of a referential constraint for the specified navigation property. Requires: The association has a referential constraint.

Parameters

Returns

ReadOnlyMetadataCollection<EdmProperty>

GetElementType

public static TypeUsage GetElementType(TypeUsage typeUsage)
If the passed in TypeUsage represents a collection this method returns final element type of the collection, otherwise it returns the value passed in.

Parameters

Returns

TypeUsage

GetPrincipalProperties

public static ReadOnlyMetadataCollection<EdmProperty> GetPrincipalProperties(NavigationProperty navProperty)
Gets the collection of properties that are on the principal end of a referential constraint for the specified navigation property. Requires: The association has a referential constraint.

Parameters

Returns

ReadOnlyMetadataCollection<EdmProperty>

GetSubtypesOf

public static IEnumerable<EntityType> GetSubtypesOf(EntityType type, ItemCollection itemCollection, bool includeAbstractTypes)
Returns the subtype of the EntityType in the current itemCollection

Parameters

Returns

IEnumerable<EntityType>

Inverse

public static NavigationProperty Inverse(NavigationProperty navProperty)
Returns the NavigationProperty that is the other end of the same association set if it is available, otherwise it returns null.

Parameters

Returns

NavigationProperty

IsCascadeDeletePrincipal

public static bool IsCascadeDeletePrincipal(AssociationEndMember associationEnd)
True if the specified association end is the principal in an identifying relationship. or if the association end has cascade delete defined.

Parameters

Returns

bool

IsCascadeDeletePrincipal

public static bool IsCascadeDeletePrincipal(NavigationProperty navProperty)
True if the source end of the specified navigation property is the principal in an identifying relationship. or if the source end has cascade delete defined.

Parameters

Returns

bool

IsIdentifyingRelationship

public static bool IsIdentifyingRelationship(AssociationType association)
True if the specified association type is an identifying relationship. In order to be an identifying relationship, the association must have a referential constraint where all of the dependent properties are part of the dependent type’s primary key.

Parameters

Returns

bool

IsKey

public static bool IsKey(EdmProperty property)
True if the EdmProperty is a key of its DeclaringType, False otherwise.

Parameters

Returns

bool

IsLazyLoadingEnabled

public static bool IsLazyLoadingEnabled(EntityContainer container)

Parameters

Returns

bool

IsNullable

public static bool IsNullable(EdmProperty property)
True if the EdmProperty TypeUsage is Nullable, False otherwise.

Parameters

Returns

bool

IsNullable

public static bool IsNullable(TypeUsage typeUsage)
True if the TypeUsage is Nullable, False otherwise.

Parameters

Returns

bool

IsPrincipalEndOfIdentifyingRelationship

public static bool IsPrincipalEndOfIdentifyingRelationship(AssociationEndMember associationEnd)
True if the specified association end is the principal end in an identifying relationship. In order to be an identifying relationship, the association must have a referential constraint where all of the dependent properties are part of the dependent type’s primary key.

Parameters

Returns

bool

IsSubtypeOf

public static bool IsSubtypeOf(EdmType firstType, EdmType secondType)
requires: firstType is not null effects: if secondType is among the base types of the firstType, return true, otherwise returns false. when firstType is same as the secondType, return false.

Parameters

Returns

bool

NeedsHandleCascadeDeleteMethod

public static bool NeedsHandleCascadeDeleteMethod(ItemCollection itemCollection, EntityType entityType)
True if this entity type requires the HandleCascadeDelete method defined and the method has not been defined on any base type

Parameters

Returns

bool

TryGetStringMetadataPropertySetting

public static bool TryGetStringMetadataPropertySetting(MetadataItem item, string propertyName, out string value)

Parameters

Returns

bool

UnderlyingClrType

public static Type UnderlyingClrType(EdmType edmType)
This method returns the underlying CLR type given the c-space type. Note that for an enum type this means that the type backing the enum will be returned, not the enum type itself.

Parameters

Returns

Type