locked
pulling entities through foreign relationship RRS feed

  • Question

  • User-1712241964 posted

    I think this would likely be something best done extending class info for my ADO.NET Entity Data Model, but not quite sure how to achieve it.   Hoping someone here has a suggestion.

    DB scenario is as follows:
    (FKA = Foreign Key from TableA, for example)

    TableA:
    PKA        FKB        FKC
    1              3              7

    TableB:
    PKB        NameB
    3              Mark

    TableC:
    PKC        NameC
    7              Robinson

    TableD:
    PKD        FKA        FKE         FKF         nchar     int

    When viewing record 1 from TableA, DD presents the record to the user displaying ‘Mark’ & ‘Robinson’.

    What I would like to achieve is, when a user is inserting a new record into TableD, I’d like the values that DD makes visible in the drop-down for the user(representing FKA) to be the ‘NameB’ and ‘NameC’ values together, perhaps separated by a space(“Mark Robinson”), instead of the int value(“1”) that is PKA, which it currently displays.

    any help would be appreciated.

    -Gary

    Thursday, August 11, 2011 3:04 PM

Answers

  • User-330204900 posted

    Hi gstadter, I always use a Computed column int he DB for this sort of thing EF and DD together do not support custom properties.

    Once you have you computed column in your DB then you use this attribute on the table

    [DisplayColumn("FullName", "LastName")]

    I don't understand why you have the name split between two tables

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 11, 2011 3:11 PM