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 5971609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:32:24+00:00 2026-05-22T20:32:24+00:00

I am building a middle size system and I am facing a problem that

  • 0

I am building a middle size system and I am facing a problem that probably some of you have faced before. In my business layer I return business objects with a subset of properties that are important for that business method, I am worried because I can end up with to much objects with meaningless names or only one where only a subset of properties are filled in a given method. Let me put an example.

Case 1

For example, a user belongs to a city, which in turns belongs to a state and a country, User, City, State and Country are tables on my database with a lot of fields, but I want a list of users with a list of Orders, so I create a business object called for example UserWithOthers with only the important properties (UserId, UserName, CityName, StateName, CountryName, List<Order>) and my DAL retrieves only that fields from Database.

Case 2

I want to return now a user with the amount of orders, I end with the following fields in my business object (UserId, UserName, CityName, StateName, CountryName, OrdersCount) and the class could be called for example UserWithOrderCount

I have thought in some options:

  1. Make that two business classes and fill them separately in each DAL method (this objects are simple but consider that method can have a complex select query that needs to be encapsulated for reuse so repository pattern doesn’t fit well here, at least I think that).
  2. Create only one object User with all the properties (UserId, UserName, CityName, StateName, CountryName, OrdersCount, List<Order>) and fill only a subset in each DAL method, but that implies Semantic Coupling when you use a method, because you must know which subset of fields are filled from database, and semantic coupling is the worst of all coupling.
  3. Option 1 doesn’t handle well if I need later in another view, both, List<Order> and OrdersCount properties.
  4. Consider now that if you use ASP.NET MVC good practices tells that you need a ViewModel to pass to the view, I thought to return ViewModels from my Businnes Layer, but I don’t think is a good idea, it feels like I am violating something, and also is not possible because my business layer is in another assembly and not the web application.
  5. I don’t want to write the same Linq query over and over again, but if use NHibernate or EFCodeFirst is “like” option one, and I will need to create tons of small business objects.

How do you handle this situation? I think this is a high level design decision.

  • 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-05-22T20:32:25+00:00Added an answer on May 22, 2026 at 8:32 pm

    First of all, I definitely agree with you about some things not do:

    1. Don’t partially-populate business objects, as you then put responsibility for knowing which properties are populated onto the business layer’s clients, which is very bad practice.

    2. Don’t return ViewModels from your business layer; your business layer is supposed to represent the business concepts of your application’s domain, and a ViewModel is a data object which contains the data necessary to display a particular view of one part of that domain – the two are very different things and the business layer should be completely unaware that its business objects are used in any kind of GUI.

    I would go with your first suggestion – create one separate business object to represent each business concept. I would then use an ORM (like EF or NHibernate) to populate those objects for me, with dedicated Repositories for each group of objects. I’d then use an application layer which calls the repositories to return whatever objects are required. to this end your Repository can include methods which return joined Users and Orders for times when you know you need to have those two types used together. This allows you to return a User with all their Orders in one query, while retaining separate, meaningful entities to represent Users and Orders.

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

Sidebar

Related Questions

I am in the middle of building a cache layer for the Redis DB
I'm building a site that has one authentication system for both general users and
I'm in the middle of building a pretty big site using asp.net (forms if
Building the same project (without any changes) produces binary different exe-files: some small regions
When building some of my PHP apps, a lot of the functionality could be
When building static libraries with VS2005 I keep getting linker warnings that VC80.pdb cant
I am building a CSS site and fail solving this partial problem: On the
I'm in the middle of building a simple windows service and I'm running into
I'm in the middle of building a web app with heavy use of jQuery
I'm in the middle of building an application but found myself too easily creating

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.