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

The Archive Base Latest Questions

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

Dear LINQ or linq2sql experts, can you help me to solve this case? I

  • 0

Dear LINQ or linq2sql experts, can you help me to solve this case?

I have Book class, every book has a List and what I want is to find the Books whose Authors lastnames in the Authors list contain a particular searchAuthor string, as follows:

string searchAuthor = "foo";
IQUeryable books = BookStaticRepository.SelectAll();

books.Where(r => r.Authors.Any(x => searchAuthor.Contains(x.lastname, StringComparison.OrdinalIgnoreCase)));

What I get it this error:

Method ‘Boolean Contains(System.String, System.String, System.StringComparison)’ has no supported translation to SQL.

I already tried the same but using IEnumerable, and it worked. I had to switch to IQueryable for performance issues… I need it to work with IQueryable.

Thanks for your help.

  • 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-26T20:12:22+00:00Added an answer on May 26, 2026 at 8:12 pm

    Hi guys thanks I found the solution myself:

    books.Where(r => r.Authors.Any(x => x.lastname.Contains(searchAuthor)));
    

    The mistake -I think- was that I was doing a sort of “opposite work”: I was saying like “the lastname has to contain the searchAuthor string” and not viceversa (the lastname has to contain the SearchAuthor string… which now gives me the results I’m expecting).

    The funny thing is that the exact same query I posted in my initial question was working fine using IEnumerable.

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

Sidebar

Related Questions

dear all.. i have a DB which built use Mysql. for this case, i
Dear all,Now i have this question in my java program,I think it should be
Dear All, please help me since I'm newbie in SQL Server. I have a
Dear stackoveflow, I have this problem. I'm working with an old version of mssql
dear all..i have this code: <script> var str=KD-R435MUN2D; var matches=str.match(/(EE|[EJU]).*(D)/i); if (matches) { var
Dear all, this is going to be tough: I have created a game object
Possible Duplicate: LINQ Between Operator Dear All, Hi, I need to write this query
I'd like to have your opinion on a specific case, please. This is about
dear all.can you tell me how to collecting this data in mysql: item colour
Dear Friends I have a Div of Images. <div class=img_team_container> <div class=img_team_subcontain> <div class=img_team><a

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.