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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:29:57+00:00 2026-05-14T08:29:57+00:00

This questions doesn’t let me sleep as it’s since one year I’m trying to

  • 0

This questions doesn’t let me sleep as it’s since one year I’m trying to find a solution but… still nothing happened in my mind. Probably you can help me, because I think this is a very common issue.

I’ve a n-layered application: presentation layer, business logic layer, model layer. Suppose for simplicity that my application contains, in the presentation layer, a form that allows a user to search for a customer. Now the user fills the filters through the UI and clicks a button. Something happens and the request arrives to presentation layer to a method like CustomerSearch(CustomerFilter myFilter). This business logic layer now keeps it simple: creates a query on the model and gets back results.

Now the question: how do you face the problem of loading data? I mean business logic layer doesn’t know that that particular method will be invoked just by that form. So I think that it doesn’t know if the requesting form needs just the Customer objects back or the Customer objects with the linked Order entities.

I try to explain better:
our form just wants to list Customers searching by surname. It has nothing to do with orders. So the business logic query will be something like:

(from c in ctx.CustomerSet
where c.Name.Contains(strQry) select c).ToList();

now this is working correctly. Two days later your boss asks you to add a form that let you search for customers like the other and you need to show the total count of orders created by each customer. Now I’d like to reuse that query and add the piece of logic that attach (includes) orders and gets back that.

How would you front this request?

Here is the best (I think) idea I had since now. I’d like to hear from you:
my CustomerSearch method in BLL doesn’t create the query directly but passes through private extension methods that compose the ObjectQuery like:

private ObjectQuery<Customer> SearchCustomers(this ObjectQuery<Customer> qry, CustomerFilter myFilter)

and

private ObjectQuery<Customer> IncludeOrders(this ObjectQuery<Customer> qry)

but this doesn’t convince me as it seems too complex.

Thanks,
Marco

  • 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-14T08:29:58+00:00Added an answer on May 14, 2026 at 8:29 am

    Consider moving to DTO’s for the interface between the presentation layer and the business layer, see for example:- http://msdn.microsoft.com/en-us/magazine/ee236638.aspx

    Something like Automapper can relieve much of the pain associated with moving to DTOs and the move will make explicit what you can and cannot do with the results of a query, i.e. if it’s on the DTO it’s loaded, if it’s not you need a different DTO.

    Your current plan sounds a rather too tightly coupled between presentation layer and data layer.

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

Sidebar

Related Questions

This seems like a basic question, but it's still bugging me. Why doesn't MyObject
I hate ask stupid questions like this, but why doesn't my code do what
I've checked through other questions and surprisingly this question doesn't seem to have been
This post asks this question but doesn't really give an answer, so I thought
I am completely perplexed. I asked this question and it (any mentioned solution) doesn't
First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow
This should be a very basic design question, but for some reason it doesn't
After looking at questions like this it doesn't make sense that my __init__(self, parrent,
I saw several specific questions about this problem - getting typeerror object doesn't support
this is quite frustrating, I saw many questions around this topic, but strangely enough

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.