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

The Archive Base Latest Questions

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

I will be starting a simple datastore-and-search project soon. Basically, one of those put

  • 0

I will be starting a simple datastore-and-search project soon. Basically, one of those “put my huge Excel spreadsheet into a database, build a web GUI for it, and make it searchable” type-things.

One thing that’s been bugging me is the actual search logic that will be used when the user enters some criteria. I am imagining a search interface with a text field, and a few other filtering tools – drop down combo boxes and check boxes and such.

While that gives me very strong, granular control over the filtering I can perform, I am wondering what SO’s thoughts are on actually performing the search. I’ll be using ASP.NET, MS SQL Server, and Linq-To-SQL here, so keep those technologies in mind.

Off the top of my head, I think I’d do something like:

var results = from s in db.Stuff
              where (s.Prop1.Contains(textFilter) ||
                     s.Prop2.Contains(textFilter) ||
                     s.Prop3.Contains(textFilter)) &&
                     checkbox1.IsChecked ?
                          s.Prop4.ToLower().Equals(combobox1.Text) : true
              select s;

Here’s what I know:

  • How to do grouping and joins if necessary
  • I can use the Contains() method on individual properties to generate SQL LIKE queries
  • I can filter things property-by-property, building my search logic as above.

Here’s what I’m asking:

  • Is there a way to search all properties (without pulling all objects into memory – which I assume means building a list of each object’s properties with reflection, stringifying them, and then checking is out)? If not, this seems incredibly cumbersome as I’d have to build new logic for every new property I might add. Something like s.Contains(textFilter) in the above would be ideal.
  • How does a SQL LIKE query actually work? Is that something I want to do?
  • Is there a standard way of implementing search rules such as quoted strings for full-matching and logical operators such as AND and OR? I would be surprised if every application that implemented them did so with custom parsing logic.
  • Am I barking up the wrong tree? Did I miss something?
  • 1 1 Answer
  • 3 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-11T18:29:58+00:00Added an answer on May 11, 2026 at 6:29 pm

    I had to create a similar search for a comments system recently. What I did was I created some extension methods off of the comments which allowed me to pass in a generic filtering object.

    Here is the sample code that I used:

    This is just a partial method and does not have the return but it will give you a picture of what I am doing:

    public List<oComment> GetComments(oCommentSearch filters)
    {
    
        using (CommentDataContext db = CommentContextFactory.CreateContext())
        {
            var query = from comment in db.COMMENTs.FilterComments(filters)
                        select comment;
        }
    }
    

    As you can see off the COMMENTs i have FilterComments. This is an extension method. This method looks like this (this is the entire class I have):

    public static class CommentExtensions
        {
            public static IQueryable<COMMENT> FilterComments(this IQueryable<COMMENT> Comments, oCommentSearch Filters)
            {
                Filters = CheckFilter(Filters);
    
                IQueryable<COMMENT> tempResult = Comments;
    
                if(Filters.Classes.Count() > 0)
                {
                    tempResult = from t in tempResult
                                 where
                                     Filters.Classes.Contains(t.CLASS_ID)
                                 select t;
                }
    
                if (Filters.Flags.Count() > 0)
                {
                    tempResult = from t in tempResult
                                 where
                                     Filters.Flags.Contains((int) t.FLAG_ID)
                                 select t;
                }
    
                if (Filters.Types.Count() > 0)
                {
                    tempResult = from t in tempResult
                                 where
                                     Filters.Types.Contains(t.CommentTypeId)
                                 select t;
                }
                return tempResult;
            }
    
            private static oCommentSearch CheckFilter(oCommentSearch Filters)
            {
                Filters.Classes  = CheckIntArray(Filters.Classes);
                Filters.Flags =  CheckIntArray(Filters.Flags) ;
                Filters.Types =  CheckIntArray(Filters.Types) ;
                return Filters;
            }
    
            private static int[] CheckIntArray(int[] ArrayToCheck)
            {
                return ArrayToCheck == null || ArrayToCheck.Count() == 0 ? new int[] {} : ArrayToCheck;
            }
        }
    

    This should get you started in the right direction for what you are trying to do.

    Hope this helps!

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

Sidebar

Related Questions

I'm starting a project that will be public facing using asp.net mvc. I know
I am starting a project for which we will have a thin client, sending
I'm starting on a project that I expect will include a substantial amount of
I am starting research on a project that will need to provide ACID semantics
I am starting a WPF project, which will be fairly complicated in complexity and
Okay, I will shortly be starting down the path of windows mobile development. I
I'm starting a Wordpress Blog that will have adult content on it, so I'll
I am starting to build a new web application that will require user accounts.
I'm starting to develop a web application in PHP that I hope will become
Will limiting a query to one result record, improve performance in a large(ish) MySQL

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.