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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:32:23+00:00 2026-05-25T17:32:23+00:00

We have our Data Access Layer setup to use repositories, services, and specifications (for

  • 0

We have our Data Access Layer setup to use repositories, services, and specifications (for predefined queries) . The service layer, when persisting data, takes in DTOs that get converted to actual entities before they are persisted. When requesting data we either get a single DTO or a collection of DTOs. The application layer only knows about the DTOs. It has no knowledge of the actual entities.

So a service and interface may look like this:

public class UserService: IUserService
{

     IUserRepository _repository;

     public UserService(IUserRepository repository)
     {
        _repository = repository
     }
     public UserDto GetByUsernameAndPassword(string username, string password)
     {
         return _repository.Find(UserSpecifications.MatchByUsernameAndPassword(username,password));
     }
}

public interface IUserService: IBaseService<UserDto>
{
     public UserDto GetByUsernameAndPassword(string username, string password);
}

Recently I have had the need to allow the application layer to generate a query to be passed into the service layer. Passing a string to do a find on an index or a single field is rather easy, it is when we want to perform sorts, filtering, and searches on an entity utilizing multiple fields that it becomes baffling to me.

Here are a couple scenarios:
A. Let’s say we have a grid control on our application. That control allows us to sort on multiple fields. We need to pass that sort expression into the service, convert that expression to a list of properties on the entity to be passed to the repository. The repository knows how to handle multiple sorts on an entity collection.

B. The application allows a user to construct a query based off fields in a DTO. The DTO looks likes this:

public class UserDto
{
    string Username {get;set;}
    string FirstName {get;set;}
    string LastName {get;set;}
    AddressDto Address{get;set;}
}

The query will be constructed in a way where the user can select fields and provide terms:
//This is and example of how the user may write a query in the system.
Where Username SartsWith “A” AND Address.City = “Myrtle Beach”

So we may have an expression we send over to the Service:

u => u.Username.StartsWith("A") && u.Address.City == "Myrtle Beach"

I am trying to figure out the best way to convert some of these thoughts in the service. Has anyone else done anything like this?

I had thought about the application filtering the results from the service, but my concern is the result set could be huge. I only wanted to bring back what was needed from the database via the repositories.

  • 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-25T17:32:24+00:00Added an answer on May 25, 2026 at 5:32 pm

    I ended up going with Lucene for my index.

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

Sidebar

Related Questions

In our data access layer at work we have this standard implementation where the
We have a Data Access service in our SOA WCF system. This service is
We are using Nhibernate as our data access layer. We have a table of
I've implemented the repository pattern on the data access layer of our current service
We have an application that generates simulated data for one of our services for
I have a table containing data about some users. Many of them use our
For a while now, my team and I have been wrapping our data access
As we all know most apps have a data access layer, often using repository
I have a data access layer which returns DataSets/DataTables by executing Stored Procedure. Everything
I have a project with a formidable data access layer using LinqtoSQL for just

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.