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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:21:35+00:00 2026-05-12T19:21:35+00:00

I have an 3-layered project, so that all Linq-Querys himself are in the DAL.

  • 0

I have an 3-layered project, so that all Linq-Querys himself are in the DAL.
Now I have a filter function implemented in the Desig-Layer and want easily filter there, but how?

            Business.UserHandling uh = new Business.UserHandling();
            List<DAL.Benutzer> users = uh.GetUserOverview();
            gridUserOverview.AutoGenerateColumns = false;
            gridUserOverview.DataSource = users;
            gridUserOverview.DataBind();

How can I user something like “users = users.Where(“bla = 1″)”?


I tried:

                Business.UserHandling uh = new Business.UserHandling();
            List<DAL.Benutzer> users = uh.GetUserOverview();

            var filters = new Dictionary<string, object>();
            filters.Add(Request.QueryString["value"], Request.QueryString["text"]);
            users = users.Where(user => filters.All(filter => user.GetType().GetProperty(filter.Key).GetValue(user, null) == filter.Value)).ToList();

            gridUserOverview.AutoGenerateColumns = false;
            gridUserOverview.DataSource = users;
            gridUserOverview.DataBind();

But it fails… I filtered on “UserID = 1”, I have 2 Users, the filter should be filter 1 of these 2. But the return is 0 users.

  • 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-12T19:21:35+00:00Added an answer on May 12, 2026 at 7:21 pm

    In order to use a dynamic filter you can build a dictionary and verify the filter by reflection:

    var filters = new Dictionary<string, object>();
    filters.Add("bla", 1);
    users.Where(user => filters.All(filter => user.GetType().GetProperty(filter.Key).GetValue(user, null) == filter.Value));
    

    Edit Support all types convertible from string:

    var users = new List<User>();
    users.Add(new User {Age = 1 });
    users.Add(new User { Age = 2 });
    var filters = new Dictionary<string, string>();
    filters.Add("Age", "1");
    var filtered = users.Where(user => filters.All(filter =>
           {
               var propertyInfo = user.GetType().GetProperty(filter.Key);
               return Equals(propertyInfo.GetValue(user, null) , Convert.ChangeType(filter.Value, propertyInfo.PropertyType));
           }));
    
    Assert.AreEqual(1, filtered.Count());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing applications which are layered as: DB<->DAL<->BL<->Service<->Presentation And that's all that
Suppose you have a layered project divided into the Presentation Layer, the Business Layer
I'm developing a project using a layered architecture. I have a DAL in which
I have a layered web application that I built with ASP.NET MVC 4, WebAPI
I have a layered application with namespaces: App.Core - business layer logic services App.Data
I have a layered worker class that I'm trying to get progress reports from.
In theory in layered architecture you can have multiple modules on the same layer.
I would like to have a layered window that is always-on-top, which I can
In a layered architecture, you have a presentation layer, logic layer and data layer.
I have a three layered Java application consisting of a presentation layer, a business

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.