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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:28:11+00:00 2026-05-11T08:28:11+00:00

For a website I’m doing we’re using LINQ to Entities. I have been charged

  • 0

For a website I’m doing we’re using LINQ to Entities. I have been charged with adding search functionality to the site. I’m trying to figure out the most elegant way to search for multiple keywords (user entered) on a single field in the database. Allow me to give an example.

Table columns:

Name, Description 

Example row:

'Cookie monster', 'Fluffy, likes cookies and blue' 

User search (delimiter doesn’t matter):

'blue fluffy'  

Currently I am using the following:

    public List<SesameCharacters> SearchByKeywords(string keywords)     {         List<SesameCharacters> output = new List<SesameCharacters>();         string[] k = keywords.ToLower().Split(' ');         using (SesameStreet_Entities entities = new SesameStreet_Entities())         {             IQueryable<SesameCharacters> filter = entities.SesameCharacters;              foreach (string keyword in k)                 filter = ForceFilter(filter, keyword);              output = filter.ToList();         }         return output;     }      private IQueryable<SesameCharacters> ForceFilter(IQueryable<SesameCharacters> filter, string keyword)     {         return filter.Where(p => p.Description.ToLower().Contains(keyword));     } 

This currently works as expected but I imagine it is not the best solution to the problem. Am I missing something glaringly obvious?

NOTE: This is AND matching.

  • 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. 2026-05-11T08:28:11+00:00Added an answer on May 11, 2026 at 8:28 am

    Looks like Linq to Entities doesn’t support contains:

    http://msdn.microsoft.com/en-us/library/bb738638.aspx

    I’d roll my own query for this one. Your probably going to want full control over the text search queries if you find out these types of searches become performance issues.

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

Sidebar

Related Questions

A website I've been working on will not match data using a PHP (preg_match)
Website using .NET Framework v3.5, SQL Server 2008, written in C# I have a
A website that I've been working on was originally created using XHTML 1.0 Transitional
My website has been giving me intermittent errors when trying to perform any Ajax
My website(D6) have Quick Enquiry Form(using webform) & i need to create a new
The website I'm create has Events. Events have a title, date, and the userids
Website in reference: http://www.imvu-e.com/products/ht/clients/test/ Notice on the tables how I have a newline separating
this website says cloudfoundry have already supproted python runtimes but when I type vmc
My website has been created with a CSS/HTML frame work that has been integrated
My website is doing some http posts to another server and I need to

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.