locked
2 & 3 level foreign Key Issues RRS feed

  • Question

  • User-1948458073 posted

    Hi! I am new to DD and I am having a issue with multiple foreign keys.  My issue is that I have 3 tables (Project, Client, Entity).  My entity table has a 1-many relation with Client.  My client table has a 1-many relationship with Projects.  When I am in view/list view of the project table, I get empty values for my clientID field...which has clientID foreign keys in the project table. 

    I would actually like show Entity field information on the project list view.  Is this possible?  If so, could you please explain in detail...maybe even provide some code would be helpful as well.

    Thanks in advance.

     

    Thursday, June 2, 2011 1:31 PM

Answers

  • User-1948458073 posted

    Thanks everyone for your feedback.  I figured out how to solve my problem.  Also...I am using Entity Framework 4.1.  Thanks again everyone.

    REQUIREMENT:
    My main requirement was to show Entity information while looking at the Project List/View table. 

    SOLUTION:
    I had to add code on the Client partial class to show Entity data, so that whenever Projects used the FK to display Client information, it grabs the Entity information instead.  I'm sure this would be obvious to many people out there, but I am newbie to DD I am still learning.

    public partial class Client
    {
    public override string ToString() { return Entity.entityNameLong; }

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 2, 2011 5:51 PM

All replies

  • User1043796333 posted

    Why don't you give us a snapshot of your diagram?

    Thursday, June 2, 2011 4:12 PM
  • User1043796333 posted

    Let me add this: FKs are shown if they exists in your model as "Navigation Properties" which are depicted in the lower part of your entity drawing.

    If it is just happens that such relationship doesn't exist in your model then there is no way you can get those values displayed

    Thursday, June 2, 2011 4:43 PM
  • User1770881099 posted

    select p.*, e.* from Project p

    join Client c on c.projectid = p.projectid

    join Entity e on e.entityid = c.entityid

    Thursday, June 2, 2011 4:53 PM
  • User1043796333 posted

    I mean, yeah!, your query is ok but what's the need in customizing from the very beginning of your project? CRUD should, as I understand should be in Dynamic Data, be done implicitly based on your model, isn't it?

    Thursday, June 2, 2011 5:01 PM
  • User-1948458073 posted

    Thanks everyone for your feedback.  I figured out how to solve my problem.  Also...I am using Entity Framework 4.1.  Thanks again everyone.

    REQUIREMENT:
    My main requirement was to show Entity information while looking at the Project List/View table. 

    SOLUTION:
    I had to add code on the Client partial class to show Entity data, so that whenever Projects used the FK to display Client information, it grabs the Entity information instead.  I'm sure this would be obvious to many people out there, but I am newbie to DD I am still learning.

    public partial class Client
    {
    public override string ToString() { return Entity.entityNameLong; }

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 2, 2011 5:51 PM