locked
Cross Linking Repositories RRS feed

  • Question

  • User1859182686 posted

    I am looking to use the repository model with an MVC based web application I am developing. I am new to MVC and the repository model so want to start off using it correctly.

    In my application I have implemented two repositories, each relating to two datasets. The first dataset provides access to a set of lookup tables. The second relates to operational data I am storing.

    In my second repository I require values from the lookup repository in order to convert values before they are stored.

    My question is, what is the best design for cross-linking repositories?

    • Have the operational repository directly reference the lookup repository. Easiest but will create an inter-dependency.
    • Handle the lookups elsewhere, in the controller (seems to defeat the point) or a further middle class
    • Any other ideas?

    Sorry if this is vague, I am trying to be generic.

    Thursday, March 29, 2012 5:19 AM

Answers

  • User1358036820 posted

    I would use interfaces and pass them to each other in constructor so there is no dependency on the concrete type and you can pass in any repository that would implement the interface.

    Hope this helps put you in the right direction.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 29, 2012 8:29 AM

All replies

  • User1358036820 posted

    I would use interfaces and pass them to each other in constructor so there is no dependency on the concrete type and you can pass in any repository that would implement the interface.

    Hope this helps put you in the right direction.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 29, 2012 8:29 AM
  • User1859182686 posted

    Hadn't thought of that approach - would help with mocking too Smile

    Thursday, March 29, 2012 9:05 AM
  • User1358036820 posted

    Yes it should.

    Thursday, March 29, 2012 11:38 AM