CodeSmith Community
Your Code. Your Way. Faster!

Many to Many... to Many?

Latest post 08-06-2008 7:46 AM by derrick1298. 7 replies.
  • 03-18-2008 10:10 AM

    Many to Many... to Many?

    Could anyone point me at the template that decides what constitutes a relationship table?

    .netTiers works as expected if my relationship tables do not contain their own auto generated primary key. 

    However, we have the case where we are linking association tables to association tables, and thus using a surrogate guid pk in all tables, including our relationship tables. 

    This appears to make netTiers think our association tables are first class entity tables, and the indirect mappings are not being generated on the first class entity objects, just the properties to get all the corresponding association table rows.

    Thanks in advance!

     Derrick

     

     

     

    • Post Points: 35
  • 03-19-2008 8:23 AM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 726
    • Points 16,910

    Re: Many to Many... to Many?

    Reply |Contact |Answer

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 03-20-2008 9:55 AM In reply to

    Re: Many to Many... to Many?

    Great, thanks! 

    • Post Points: 35
  • 05-07-2008 6:38 PM In reply to

    • rhettc
    • Top 150 Contributor
    • Joined on 05-02-2007
    • Posts 28
    • Points 666

    Re: Many to Many... to Many?

    Derrick, were you able to modify this to get the results you wanted? 

     I also have a database that uses surrogate keys in the join tables... Is it really as simple as getting the template to recogize these as many to many relationships?  Does anyone know if the generated code in the service base class would work properly with this modification?  Maybe I'm asking if there are any known issues with doing this, I realize I'd have to test whatever sort of modifications I made to the template Smile

    Filed under: ,
    • Post Points: 5
  • 05-08-2008 11:05 AM In reply to

    • rhettc
    • Top 150 Contributor
    • Joined on 05-02-2007
    • Posts 28
    • Points 666

    Re: Many to Many... to Many?

    I was able to modify the code in CommonSqlCode.cs so that it recognized my junction tables.  After that some many to many relationships were modeled without issue.  However the template started to crash before it could complete.  I think it had problems generating names for methods.  Anyhow, we have deicided to change our tables so that the FK columns are the PK and we'll just leave the identity column intact. 

    • Post Points: 35
  • 08-05-2008 4:29 PM In reply to

    Re: Many to Many... to Many?

    rhettc,

    Sorry, haven't stopped by in a few months.

    But basically, yes, that is what we did also.

    I am here for a new problem though, so off to post...

    derrick

    • Post Points: 35
  • 08-05-2008 10:54 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 342
    • Points 8,610

    Re: Many to Many... to Many?

    Can you post some tables that you think should work?  And the tables you are using.  Doesn't have to be anything complex, just enough to make it break.

    A Sql script would be awesome and what sort of code breaks it:  whether it is just the generated code won't compile or that certain code makes it break.

    jeff

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 35
  • 08-06-2008 7:46 AM In reply to

    Re: Many to Many... to Many?

    say you have tables A, B, and AB

    A.Id
    A.Name

    B.Id
    B.Name

    AB.Id
    AB.AId
    AB.BId

    When we had AB.Id as the PK, we didn't get the auto BCollection_From_AB method on A.  Chaning the PK to be the combination of AId and BId, and adding a unique index on AB.Id, did the trick, then we got BCollection_From_AB on A.

    derrick

    • Post Points: 5
Page 1 of 1 (8 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems