Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 466809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:31:04+00:00 2026-05-12T23:31:04+00:00

I’m wondering what the recommended approach is for dealing with relational data with the

  • 0

I’m wondering what the recommended approach is for dealing with relational data with the IRepository pattern.

My database has the following tables with column names in parenthesis:

  • Plans (PlanId, Name, CreationDate,
    ModifiedDate, ViewId)
  • Areas (AreaId, Name, nTop, nLeft,
    nRight, nBottom)
  • Views (ViewId, nTop, nLeft, nRight,
    nBottom)
  • PlanAreas (PlanId, AreaId)

Where each plan can have zero or many Areas but only one view, so Plans.ViewId is FK to Views.ViewId. In PlanAreas, both columns are FK to the respective tables.

There are times when my application might want to act independently on the areas, but usually I will be loading, saving, deleting a plan and all of its constituents (areas, views) at the same time.

I’ve started down the path ….

public interface IPlanRepository
{
   IEnumerable<MyModel.Plan> GetAll();
   MyModel.Plan GetByName(string sName);
   MyModel.Plan GetById(string sId);
   void Delete(MyModel.Plan plan);
   void SaveOrUpdate(MyModel.Plan plan);
}

public class Plan
{
   public Guid Id { get; set; }
   public string Name { get; set; }
   public DateTime Creation { get; set; }
   public DateTime Modified { get; set; }
   public MyModel.View View { get; set; }
   public IList<MyModel.Area> Areas { get; set; }
}

public class View
{
   public Guid Id { get; set; }
   public IEnvelope Envelope { get; set; } // encapsulates top, left, bottom, right
}

// etc.

The plan is fairly complex, so there will actually be more properties, but this is a good start. So now for the questions:

  • Do I need IViewRepository and IAreaRepository?
  • When implementing the methods in IPlanRepository, do I do all of the work of grabbing the relational data tied to a plan (i.e. Areas, and View) and return a fully populated Plan object?
  • Or is it better to have a higher-level “aggregator” (for lack of a better word) that will fill in the properties once the Plan is returned? Something like this:

    Plan GetPlanById(string sId)
    {
        Plan myplan = new Plan();
        IPlanRepository planrepo = new PlanRepoImpl();
        myplan = planrepo.GetById(sId); 
        IViewRepository viewrepo = new ViewRepoImpl();
        myplan.View = viewrepo.GetByPlanId(sId);
        return myplan;
    }
    

Right now I’m planning on using LINQ-SQL for my data access because I’m familiar with it, and I can do it fairly quickly. I may switch to something else down the line, but I want to keep it simple for now.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:31:04+00:00Added an answer on May 12, 2026 at 11:31 pm

    You definitely do not need a repository for the sub parts of a plan. Since they are internal to the model you probably do not need to access them directly and if you did you would probably need a reference to the plan anyway.

    Since that is the case you would want to use the Plan as your main point of reference. Using a full populated plan object you can then find out anything you want to know about the areas and views that are associated with it.

    EDIT:
    I have been reading the DDD book by Eric Evans lately and for his repository he used a similar style to what I have described above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.