Entity Splitting: Mapping the same table twice. RRS feed

  • Question

  • I have several entities which map to a user table twice. That is, a single row in a table has a "created by" usercode and a "last updated by" user code.
    I want to return the User names for both columns along with my entity. I can easily see how to combine the entities for one or other of the usercode fields, but not both together.
    Does anyone know if this is possible? Or will I have to resort to a Linq query?
    Tuesday, October 18, 2011 8:33 AM

All replies

  • Hi Peter,

    Entity Splitting involves mapping a single entity in the conceptual layer to multiple tables in the store. The relationship between the two tables is 1 to 1, but I'm not very sure about your requirement. I'd like to give your a related link here: Would you please clarify me. thanks.

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, October 20, 2011 6:52 AM
  • Hi Alan,

    Thanks very much for the Link.

    Below is an example of the relationships I am describing....


    As you can see. The Suppliers table has two foreign key relationships to the Users Table. One for CreationUserCode, and one for LastUpdateUserCode. Both map to the User_Code column in the Users Table.
    What I would like to be able to do is, bring into the entity the "First_Name" and "Last_Name" columns for the "Created By" User and the "Last Updated By" User. This way I can fill any Datagrids with more friendly data, without needing to build Linq Queries.
    Using Table Mapping, I can successfully map say, the CreationUserCode to the users Table. However, when I try to map the
    Users Table again for the LastUpdatedByUserCode, the drop down no longer shows the Users Table.....

    I hope this makes things clearer!
    Thanks very much for your help!

    Thursday, October 20, 2011 12:52 PM
  • Has anyone got any ideas on this?
    Friday, October 28, 2011 1:34 PM
  • Bump!
    Pete Gallagher - IT Consultant - PJG Creations
    Tuesday, November 8, 2011 6:48 PM