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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:02:10+00:00 2026-05-28T01:02:10+00:00

I have been trying to implement a search page for the admin of my

  • 0

I have been trying to implement a search page for the admin of my system. Long story short, there a 3 paramaters as criterias. 1. users, 2.projects, 3. customers. The admin can make any combination of those three criterias. for example “I would like to see all users which are assigned to this projects and also all the customers” or “I want to see this customer and this project but all the users” and so on. How do you implement such filtering? I am using asp.net 4.0 and linq just in case.

Here is the function content and it is all. I have made it by if conditions but it is not at all healthy.

public static List<Data.CurrentActivity> GetUsersActivitySearch(string employeeId, string projectId, string customerId, DateTime startDate, DateTime endDate)
        {
            DataClassesDataContext dc = new DataClassesDataContext(General.ConnectionString);

            if(projectId=="" && customerId!="")
              return  dc.CurrentActivities.Where(t => t.User.RecId.ToString() == employeeId && t.Customer.RecId.ToString() == customerId && t.ActivityDate >= startDate && t.ActivityDate <= endDate).ToList();
            else if (projectId != "" && customerId == "")
                return dc.CurrentActivities.Where(t => t.User.RecId.ToString() == employeeId && t.Project.RecId.ToString() == projectId && t.ActivityDate >= startDate && t.ActivityDate <= endDate).ToList();
            else if (projectId != "" && customerId != "")
                return dc.CurrentActivities.Where(t=>t.User.RecId.ToString()==employeeId && t.Customer.RecId.ToString()==customerId && t.Project.RecId.ToString()==projectId && t.ActivityDate>=startDate && t.ActivityDate<=endDate).ToList();
            return dc.CurrentActivities.Where(t => t.User.RecId.ToString() == employeeId && t.ActivityDate >= startDate && t.ActivityDate <= endDate).ToList();
        }
  • 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-28T01:02:11+00:00Added an answer on May 28, 2026 at 1:02 am

    Now that I see your code, i have a easy solution. You can actually compound where clause on the IQueryable interface because of the lazy execution:

            DataClassesDataContext dc = new DataClassesDataContext(General.ConnectionString);
            var result = dc.CurrentActivies.Where(t.ActivityDate >= startDate && t.ActivityDate <= endDate);
    
            if(userId.Length > 0)
                result = result.Where(t => t.User.RecId.ToString() == employeeId);
    
            if (projectId.Length > 0)
                result = result.Where(t => t.Project.RecId.ToString() == projectId);
    
            if (customerId.Length > 0)
                result = result.Where(t=>t.Customer.RecId.ToString()==customerId);
    
            return result.ToList();
    

    If you had a generalized object that could represent enough information to display your results. Then you could do something like this:

    public IList<SearchResults> Search(string user, string customer, string project)
    {
        return (from user in context.Users
            where SqlMethods.Like(user.Name, user) && user.Length > 0
            select new SearchResult
            {
                ... properties you care about
            })
            .Concat(from project in context.Projects
                 where SqlMethods.Like(project, project.Name) && project.Length > 0
                 select new SearchResult
                 {
                     ///
                 })
            .Concat(from customer in context.Customers
                 where SqlMethods.Like(customer, customer.Name) && customer.Length > 0
                 select new SearchResult
                 {
                     ///
                 })
            .ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to implement proximity search using Lucene 3.6 . I went
I have been trying to implement an upgrade plan for my Android app which
I have been trying to implement a GlassPane for my games' in-game HUD, but
Hello guys, I have been trying to implement the DSUM function but failed to
I have been trying for the past two days now to implement Admob ads
I have been having this annoying problem when trying to implement a picture gallery
Im trying to implement an Observer/Observable pattern on an EC2 instance. I have been
I have been trying to implement a stack on dev c with c ,
I have been trying to implement Chris Coyier's inline-block + text justify solution to
I have been trying to search for a solution, but with very little success.

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.