C# Class EFUtility.CodeGenerationTools.MetadataTools

Responsible for making the Entity Framework Metadata more accessible for code generation.
Mostra file Open project: jradxl/Entity-Framework-Code-Generation-Tools-Experiments Class Usage Examples

Public Methods

Method Description
ClrType ( TypeUsage typeUsage ) : Type

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.

GetCorrespondingDependentProperty ( System.Data.Metadata.Edm.NavigationProperty navProperty, System.Data.Metadata.Edm.EdmProperty principalProperty ) : System.Data.Metadata.Edm.EdmProperty

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.

GetCorrespondingPrincipalProperty ( System.Data.Metadata.Edm.NavigationProperty navProperty, System.Data.Metadata.Edm.EdmProperty dependentProperty ) : System.Data.Metadata.Edm.EdmProperty

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.

GetDependentProperties ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : ReadOnlyMetadataCollection

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.

GetElementType ( TypeUsage 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.

GetPrincipalProperties ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : ReadOnlyMetadataCollection

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.

GetSubtypesOf ( EntityType type, ItemCollection itemCollection, bool includeAbstractTypes ) : IEnumerable

Returns the subtype of the EntityType in the current itemCollection

Inverse ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : System.Data.Metadata.Edm.NavigationProperty

Returns the NavigationProperty that is the other end of the same association set if it is available, otherwise it returns null.

IsCascadeDeletePrincipal ( System.Data.Metadata.Edm.AssociationEndMember associationEnd ) : bool

True if the specified association end is the principal in an identifying relationship. or if the association end has cascade delete defined.

IsCascadeDeletePrincipal ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : bool

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.

IsIdentifyingRelationship ( System.Data.Metadata.Edm.AssociationType association ) : bool

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.

IsKey ( System.Data.Metadata.Edm.EdmProperty property ) : bool

True if the EdmProperty is a key of its DeclaringType, False otherwise.

IsNullable ( System.Data.Metadata.Edm.EdmProperty property ) : bool

True if the EdmProperty TypeUsage is Nullable, False otherwise.

IsNullable ( TypeUsage typeUsage ) : bool

True if the TypeUsage is Nullable, False otherwise.

IsPrincipalEndOfIdentifyingRelationship ( System.Data.Metadata.Edm.AssociationEndMember associationEnd ) : bool

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.

IsSubtypeOf ( System.Data.Metadata.Edm.EdmType firstType, System.Data.Metadata.Edm.EdmType secondType ) : bool

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.

MetadataTools ( object textTransformation ) : System

Initializes an MetadataTools Instance with the TextTransformation (T4 generated class) that is currently running

NeedsHandleCascadeDeleteMethod ( ItemCollection itemCollection, EntityType entity ) : bool

True if this entity type requires the HandleCascadeDelete method defined and the method has not been defined on any base type

TryGetStringMetadataPropertySetting ( System.Data.Metadata.Edm.MetadataItem item, string propertyName, string &value ) : bool
UnderlyingClrType ( System.Data.Metadata.Edm.EdmType edmType ) : Type

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.

Private Methods

Method Description
ContainsCascadeDeleteAssociation ( ItemCollection itemCollection, EntityType entity ) : bool

True if this entity type participates in any relationships where the other end has an OnDelete cascade delete defined, or if it is the dependent in any identifying relationships

Method Details

ClrType() public method

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.
public ClrType ( TypeUsage typeUsage ) : Type
typeUsage TypeUsage
return System.Type

GetCorrespondingDependentProperty() public method

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.
public GetCorrespondingDependentProperty ( System.Data.Metadata.Edm.NavigationProperty navProperty, System.Data.Metadata.Edm.EdmProperty principalProperty ) : System.Data.Metadata.Edm.EdmProperty
navProperty System.Data.Metadata.Edm.NavigationProperty
principalProperty System.Data.Metadata.Edm.EdmProperty
return System.Data.Metadata.Edm.EdmProperty

GetCorrespondingPrincipalProperty() public method

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.
public GetCorrespondingPrincipalProperty ( System.Data.Metadata.Edm.NavigationProperty navProperty, System.Data.Metadata.Edm.EdmProperty dependentProperty ) : System.Data.Metadata.Edm.EdmProperty
navProperty System.Data.Metadata.Edm.NavigationProperty
dependentProperty System.Data.Metadata.Edm.EdmProperty
return System.Data.Metadata.Edm.EdmProperty

GetDependentProperties() public method

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.
public GetDependentProperties ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : ReadOnlyMetadataCollection
navProperty System.Data.Metadata.Edm.NavigationProperty
return ReadOnlyMetadataCollection

GetElementType() public method

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

GetPrincipalProperties() public method

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.
public GetPrincipalProperties ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : ReadOnlyMetadataCollection
navProperty System.Data.Metadata.Edm.NavigationProperty
return ReadOnlyMetadataCollection

GetSubtypesOf() public method

Returns the subtype of the EntityType in the current itemCollection
public GetSubtypesOf ( EntityType type, ItemCollection itemCollection, bool includeAbstractTypes ) : IEnumerable
type System.Data.Metadata.Edm.EntityType
itemCollection ItemCollection
includeAbstractTypes bool
return IEnumerable

Inverse() public method

Returns the NavigationProperty that is the other end of the same association set if it is available, otherwise it returns null.
public Inverse ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : System.Data.Metadata.Edm.NavigationProperty
navProperty System.Data.Metadata.Edm.NavigationProperty
return System.Data.Metadata.Edm.NavigationProperty

IsCascadeDeletePrincipal() public method

True if the specified association end is the principal in an identifying relationship. or if the association end has cascade delete defined.
public IsCascadeDeletePrincipal ( System.Data.Metadata.Edm.AssociationEndMember associationEnd ) : bool
associationEnd System.Data.Metadata.Edm.AssociationEndMember
return bool

IsCascadeDeletePrincipal() public method

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.
public IsCascadeDeletePrincipal ( System.Data.Metadata.Edm.NavigationProperty navProperty ) : bool
navProperty System.Data.Metadata.Edm.NavigationProperty
return bool

IsIdentifyingRelationship() public method

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.
public IsIdentifyingRelationship ( System.Data.Metadata.Edm.AssociationType association ) : bool
association System.Data.Metadata.Edm.AssociationType
return bool

IsKey() public method

True if the EdmProperty is a key of its DeclaringType, False otherwise.
public IsKey ( System.Data.Metadata.Edm.EdmProperty property ) : bool
property System.Data.Metadata.Edm.EdmProperty
return bool

IsNullable() public method

True if the EdmProperty TypeUsage is Nullable, False otherwise.
public IsNullable ( System.Data.Metadata.Edm.EdmProperty property ) : bool
property System.Data.Metadata.Edm.EdmProperty
return bool

IsNullable() public method

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

IsPrincipalEndOfIdentifyingRelationship() public method

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.
public IsPrincipalEndOfIdentifyingRelationship ( System.Data.Metadata.Edm.AssociationEndMember associationEnd ) : bool
associationEnd System.Data.Metadata.Edm.AssociationEndMember
return bool

IsSubtypeOf() public method

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.
public IsSubtypeOf ( System.Data.Metadata.Edm.EdmType firstType, System.Data.Metadata.Edm.EdmType secondType ) : bool
firstType System.Data.Metadata.Edm.EdmType
secondType System.Data.Metadata.Edm.EdmType
return bool

MetadataTools() public method

Initializes an MetadataTools Instance with the TextTransformation (T4 generated class) that is currently running
public MetadataTools ( object textTransformation ) : System
textTransformation object
return System

NeedsHandleCascadeDeleteMethod() public method

True if this entity type requires the HandleCascadeDelete method defined and the method has not been defined on any base type
public NeedsHandleCascadeDeleteMethod ( ItemCollection itemCollection, EntityType entity ) : bool
itemCollection ItemCollection
entity System.Data.Metadata.Edm.EntityType
return bool

TryGetStringMetadataPropertySetting() public static method

public static TryGetStringMetadataPropertySetting ( System.Data.Metadata.Edm.MetadataItem item, string propertyName, string &value ) : bool
item System.Data.Metadata.Edm.MetadataItem
propertyName string
value string
return bool

UnderlyingClrType() public method

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.
public UnderlyingClrType ( System.Data.Metadata.Edm.EdmType edmType ) : Type
edmType System.Data.Metadata.Edm.EdmType
return System.Type