locked
help with metadata class RRS feed

  • Question

  • User-15190661 posted

    any help gratefully appreciated. i have a metdata class set up as follows (for testing):

    <ScaffoldTable(True)> <DisplayName("My Details")> <MetadataType(GetType(tblContact.tblContactMD))> _
    Partial Public Class tblContact
    Public Class tblContactMD

    Private _FirstNames As String
    <DisplayName("First Name")> _
    Public Property FirstNames() As String
    Get
    Return "1"
    End Get
    Set(ByVal value As String)
    Me._FirstNames = "1"
    End Set
    End Property

    as you can see the property set and get both set the column to be "1" so surely i should see this as the value when the column is displayed in any dynamic data form?

    however i still see the value of the underlying field from the database. i am obviously missing something here - any ideas?

    john

    Wednesday, June 27, 2012 11:14 AM

Answers

  • User-330204900 posted

    For 1. A buddy or Metadata class is a class nested inside another class

    your partial class is

    tblContact

    and your Metadata class is

    tblContactMD

    this Metadata class is is never called as it is just used as a work around to be able to add metadata to your data model and since the classes for your data mode is generated you can't add attribute there as every time you rebuild it it will wipe out your attribute.

    And for 2. because this is a property of you Metadata class which is nested in the real class of you entity the property will never be called.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2012 6:08 PM
  • User-330204900 posted

    You would be best doing that in either

    • A custom Field Template
    • Your DataModel partial methods
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 30, 2012 4:09 AM

All replies

  • User-330204900 posted

    Hi there Jrees, you cannot do this for two reasons

    <ScaffoldTable(True)> <DisplayName("My Details")> <MetadataType(GetType(tblContact.tblContactMD))> _
    Partial Public Class tblContact
        Public Class tblContactMD
    
            Private _FirstNames As String
            <DisplayName("First Name")> _
            Public Property FirstNames() As String
                Get
                    Return "1"
                End Get
                Set(ByVal value As String)
                    Me._FirstNames = "1"
                End Set
            End Property
    
        End Class
    End Class

    1 you are trying to do this in the buddy / metdata class and so the getter and setter is never called and 2 there is problable an property in your class already with that name? and you cannot have two properties with the same name.

    Thursday, June 28, 2012 8:06 AM
  • User-15190661 posted

    sorry can you explain "1 you are trying to do this in the buddy / metdata class and so the getter and setter is never called" to me?

    this indeed seems to be the case as when i put debug breakpoints on the code they never get fired. however i am now not sure WHERE i should be putting this code?

    john

    Thursday, June 28, 2012 8:53 AM
  • User-330204900 posted

    For 1. A buddy or Metadata class is a class nested inside another class

    your partial class is

    tblContact

    and your Metadata class is

    tblContactMD

    this Metadata class is is never called as it is just used as a work around to be able to add metadata to your data model and since the classes for your data mode is generated you can't add attribute there as every time you rebuild it it will wipe out your attribute.

    And for 2. because this is a property of you Metadata class which is nested in the real class of you entity the property will never be called.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2012 6:08 PM
  • User-15190661 posted

    ok thanks for that info. can you adise me then how i best i can modify the field value in code?

    Friday, June 29, 2012 6:07 AM
  • User-330204900 posted

    You would be best doing that in either

    • A custom Field Template
    • Your DataModel partial methods
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 30, 2012 4:09 AM