Linq to Sql using a "non-column attribute" property in an association RRS feed

  • Question

  • Hello,
    I am trying to create an association between 2 linq to sql entities, say Entity A and Entity B.
     A uses a non-column attribute property ( named BaseDocumentType which is a constant value ) and a column attribute in an Association for "ThisKey" and 2 column attributes for "OtherKey".  The following is an example of my Association attribute definition...

    [System.Data.Linq.Mapping.AssociationAttribute ( ... ThisKey = "BaseDocumentType, Column2" , OtherKey = "Column1,Column2" )]

    When I run it I get the following error...
    "Data member 'System.String BaseDocumentType' of type 'Library' is not part of the mapping for type 'A'. Is the member above the root of an inheritance hierarchy?"

    What is the best way to do this... or the best way to make it work?


    Friday, July 5, 2013 3:06 PM


  • Hi emidiod;

    According to the Microsoft documentation, AssociationAttribute.ThisKey Property, it states that it "Gets or sets members of this entity class to represent the key values on this side of the association.", therefore if BaseDocumentType is not a member of the entity it can't be used.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Chester Hong Thursday, July 18, 2013 2:11 AM
    Friday, July 5, 2013 5:41 PM