Customize Code Generation in EF: VB.NET: Search Metadata Properties: Listing 1

The NoDataMember method searches the metadata properties of the current item. There is a metadata property for all EDMX annotations, which are XML attributes on the Property or EntityType elements. The calling code adds the returned list to the AdditionalAttributes property of the event arguments of the OnPropertyGeneration event.

Private Const InstructionsEdmxAttributeName As String = _
Private Const InstructionNoDataMember As String = _
Private Const RemoveDataMemberClrAttributeName As String = _
Private Function NoDataMember(ByVal item As MetadataItem) _
    As IList(Of CodeAttributeDeclaration)
    Dim codeAttributeDeclarations As New List(Of _
    If item IsNot Nothing Then
        Dim metadataProperties = From prop In _
            item.MetadataProperties _
            Where prop.Name = InstructionsEdmxAttributeName _
            AndAlso prop.Value IsNot Nothing _
            AndAlso prop.Value.ToString() = InstructionNoDataMember
        If metadataProperties.Count > 0 Then
            codeAttributeDeclarations.Add(GetNewClrAttribute( _
        End If
    End If
    Return codeAttributeDeclarations
End Function
comments powered by Disqus


.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events