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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:45:04+00:00 2026-05-15T11:45:04+00:00

I had asked this question in a much more long-winded way a few days

  • 0

I had asked this question in a much more long-winded way a few days ago, and the fact that I got no answers isn’t surprising considering the length, so I figured I’d get more to the point.

I have to make a decision about what to display a user based on their assignment to a particular customer. The domain object looks like this vastly simplified example:

public class Customer
{
    public string Name { get; set; }
    public IEnumerable<Users> AssignedUsers { get; set; }
}

In the real world, I’ll also be evaluating whether they have permissions (using bitwise comparisons on security flags) to view this particular customer even if they aren’t directly assigned to it.

I’m trying to stick to domain-driven design (DDD) principles here. Also, I’m using LINQ to SQL for my data access. In my service layer, I supply the user requesting the list of customers, which right now is about 1000 items and growing by about 2% a month.

If I am strict about keeping logic in my service layer, I will need to use Linq to do a .Where that evaluates whether the AssignedUsers list contains the user requesting the list. This will cause a cascade of queries for each Customer as the system enumerates through. I haven’t done any testing, but this seems inefficient.

If I fudge on the no-logic-in-the-data, then I could simply have a GetCustomersByUser() method that will do an EXISTS type of SQL query and evaluate security at the same time. This will surely be way faster, but now I’m talking about logic creeping into the database, which might create problems later.

I’m sure this is a common question people come up on when rolling out Linq…any suggestions on which way is better? Is the performance hit of Linq’s multiple queries better than logic in my database?

  • 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-15T11:45:05+00:00Added an answer on May 15, 2026 at 11:45 am

    Which is worse?
    Depends who you ask.

    Possibly if you ask the DDD ultra-purist they’ll say logic in the database is worse.

    If you ask pretty much anyone else, IMHO, especially your end users, pragmatic developers and the people who pay for the hardware and the software development, they’ll probably say a large performance hit is worse.

    DDD has much to commend it, as do lots of other design approaches, but they all fall down if you dogmatically follow them to the point of coming up with a “pure” design at the expense of real world considerations, such as performance.

    If your really are having to perform this sort of query on data, then the database is almost certainly far better at performing the task.

    Alternatively, have you “missed a trick” here. Is your design, however DDD, actually not right?

    Overall – use your tools appropriately. By all means strive to keep logic cleanly seperated in your service layer, but not when that logic is doing large amounts of work that a database is designed for.

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

Sidebar

Related Questions

Today i was asked this question about sharing data from a thread t1 that
I was asked this question in an interview. Although the interview was for dot
I've kind of asked this question before - What does JVM flag CMSClassUnloadingEnabled actually
I've seen this question asked around before, and found an answer for how to
So, if this question has been asked before, I'm sorry. I'm not exactly sure
I asked the question below couple of weeks ago. Now, when reviewing my question
If I had a normal website this would be a simple enough fix... but
In an earlier question I asked about sanitizing postal street addresses, one of the
I was playing around with list comprehensions to get a better understanding of them
I’m after some thoughts on how people go about calculating database load for the

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.