2

I know Where() searches through my database for anything that matches and returns me a list, however it matches whole words. How do you search through the database and find everything without matching whole words?

For example, the user wants to search for: funny

then my search function will return anything that has the word "funny" in it, such as

  • funnygirls
  • funnydogs
  • funnypeople
  • funnybikes; etc...

I implemented the Where(), but it doesn't do the feature above? Is there any fixes? or any Alternatives?

Edit:

Context Code:

   public static List<PhotoAlbumDto> searchAlbumsFromDA(string inputName)
   {
       EzPrintsEntities db = new EzPrintsEntities();
       List<PhotoAlbum> albums = new List<PhotoAlbum>();
       albums = db.PhotoAlbums.Where(b => b.NAME == inputName).ToList();
   }

This returns me only things that match "funny" EXACTLY... so in other words, I can't search up everything that only has the word "funny" in it, such as funnycats... Only "funny" will be returned, and nothing else.

Charles
  • 450
  • 1
  • 4
  • 20

1 Answers1

3

Try something like

albums = db.PhotoAlbums.Where(b => b.NAME.Contains("funny")).ToList();
Forty-Two
  • 7,535
  • 2
  • 37
  • 54