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

  • SEARCH
  • Home
  • 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 8390415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:58:48+00:00 2026-06-09T18:58:48+00:00

I am new to Entity Framework and I want to get some points about

  • 0

I am new to Entity Framework and I want to get some points about the constellation EF, LINQ, POCOs and repositories.

We have a working solution with a repository which uses EF and POCOs to access the database. We are doing all our queries in LINQ through the context. We added the mapping into mapping classes which are loaded at the application start as the database/tables are already existing.

If I have a business case where I need to calculate for a specific company the amount of toys bought by the employees for their children.

How would I build up the repository / repositories?

A: call with one repository all employees of a company and then call in the service layer again another repo for every employee the children and so on?

B: call one repository which returns me the company with all employees, children and the toys?

A seems to me much cleaner and I can reuse the repositories more often. But B seams to be the more efficient but not reusable so much. Less repositories and the queries would get bigger and bigger.

That is just a small example… but we have much larger business cases. What is the best architectural approach in this case?

class Company
{
    List<Employee> employees;
}

class Employee
{
    List<Child> children;
}

class Child
{
    List<Toy> toys;
}
  • 1 1 Answer
  • 0 Views
  • 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-06-09T18:58:50+00:00Added an answer on June 9, 2026 at 6:58 pm

    You don’t need to call repository to get company, employee, children and toys!

    I need to calculate for a specific Company the amount of Toys bought by the employees for there children

    So your business case is to have a single number or maybe number per toy or number per employee. You don’t need to load all those entities and compute it in your application. You just need to write an aggregation query (either in Linq or SQL). This whole computation is supposed to run in the database.

    If you need to hide the query behind the repository simply choose one where this business case belongs and expose the query as a new method for the repository.

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

Sidebar

Related Questions

I am new to Entity Framework and Linq to Entities and I want to
I heard about the new entity framework for .net, and decided to modify my
When adding a new Entity Framework object to a database, how could one have
I'm new to Entity Framework and am using Database First. I have inherited a
I'm new to the entity framework and I'm really confused about how savechanges works.
I have created a new application using Entity Framework 4.3 database migrations. The migrations
I have following Entity Framework Logic, and I want to translate to Stored Procedure,
I have some code that I use with Entity Framework like class Person{ pubic
I have a 'Customer' POCO entity within my Entity Framework 4 project. I want
I am using ASP.NET MVC 3 with Entity Framework 4 using POCOs and want

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.