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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:33:51+00:00 2026-05-29T05:33:51+00:00

i have a function: private IEnumerable<Promotion> MatchesKeyword(IEnumerable<Promotion> list, String keyword) { …snip… } which

  • 0

i have a function:

private IEnumerable<Promotion> MatchesKeyword(IEnumerable<Promotion> list, String keyword)
{
   ...snip...
}

which right now performs a LINQ query:

private IEnumerable<Promotion> MatchesKeyword(IEnumerable<Promotion> list, String keyword)
{
   return list.Where(item => item.Name.ContainsText(keyword)
      || item.Description.ContainsText(keyword)
      ...snip...
   );
}

This code works well enough.

But i need to convert it to use a PredicateBuilder:

private IEnumerable<Promotion> MatchesKeyword(IEnumerable<Promotion> list, String keyword)
{
   var predicate = PredicateBuilder.False<Promotion>();     

   predicate = predicate.Or(item => item.Name.ContainsText(keyword)
         || item.Description.ContainsText(keyword)
         ...snip...
   );

   return list.Where(predicate);
}

Which, strangely, doesn’t compile. The failing line is:

return list.Where(predicate);

You can take your pick of the errors:

  • Instance argument: cannot convert from ‘System.Collections.Generic.IEnumerable’ to ‘System.Linq.IQueryable’
  • ‘System.Collections.Generic.IEnumerable’ does not contain a definition for ‘Where’ and the best extension method overload ‘System.Linq.Enumerable.Where(System.Collections.Generic.IEnumerable, System.Func)’ has some invalid arguments
  • Argument 2: cannot convert from ‘System.Linq.Expressions.Expression>’ to ‘System.Func’

What’s the problem? IEnumerable goes in, IEnumerable comes out.

i’ll be honest, i read the page on PredicateBuilder and i don’t understand any of it.


A hint of why i need to change to PredicateBuilder is:

private IEnumerable<Promotion> MatchesKeyword(IEnumerable<Promotion> list, String keyword)
{
   var predicate = PredicateBuilder.False<Promotion>();     

   predicate = predicate.Or(item => item.Name.ContainsText(keyword)
         || item.Description.ContainsText(keyword)
         ...snip...
   );

   DateTime dt = TryStrToDate(keyword);
   if (dt)
       predicate = predicate.Or(item => item.PromotionDate == dt);

   return list.Where(predicate);
}

…not that i need a reason, problem, practical example, or research effort to ask a question.

  • 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-29T05:33:52+00:00Added an answer on May 29, 2026 at 5:33 am

    PredicateBuilder needs an IQueryable<T> to do its magic. Just change the last line in your example to

    return list.AsQueryable().Where(predicate);
    

    to make it work.

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

Sidebar

Related Questions

I have a label function like : private function formatDate (item:Object, column:DataGridColumn):String { var
I have the following serialization method: Private Function SerializeData(ByVal data As cData) As String
I have this function... private string dateConvert(string datDate) { System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo(en-GB);
If I have a method such as: private function testMethod(param:string):void { // Get the
I have a ComboBox with a label function like this one: private function fieldLabelFunction(item:Object):String
I have the following function private byte[] Function(string url) { HttpWebRequest webRequest= (HttpWebRequest)WebRequest.Create(url); webRequest.AddRange(0,
I have this function : private void Pager(IEnumerable<t> tEnum) { ... } and I'd
I have the following function: private void populate() { String connectionString = Properties.Settings.Default.Database; String
I have a function like this in actionscript3 private function uploadFile(event:MouseEvent):void { var uploader:URLRequest
I have the following simple function: private void EnableDisable941ScheduleBButton() { if (this._uosDepositorFrequency.Value != null)

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.