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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:19:14+00:00 2026-05-30T15:19:14+00:00

I was looking up an example how to use a particular part of the

  • 0

I was looking up an example how to use a particular part of the Telerik grid framework (ASP.NET MVC3, but that’s not really relevant here). They have a chunk of code which takes a list of filter descriptions and builds an expression:

System.Linq.Expressions.Expression<Func<MyModel, bool> exp = 
               ExpressionBuilder.Expression<MyModel>(listOfFilters);

Ok, so I think that’s fine. The Expression wraps a lambda, which operates on MyModel to produce a bool. Great. Now, their example simply drops that into a Where like so:

someList = someList.Where(exp);

Which I am presuming should be “hey apply that expression to all the items in the list (which is of course generic MyModel too). However, VS claims that code doesn’t compile. I get “No overload Where exists or System.Func has some invalid arguments”.

I played around with it and find that I can compile the expression, which gives the more unseemly looking

someList = someList.Where(x => exp.Compile()(x));

Which does compile and would probably work, but it makes me uncomfortable because I’m now clearly operating outside what I know.

Is there some reason why (IDE setting, flag, stale documentation) the example’s approach doesn’t work?
Is there a rough equivalency to my hack and the example?
Should I structure that hack differently to avoid some hideous problem (like, its not going to compile the expression each and every time it checks an item in the list, right? I think it’s smart enough for that?)

— Edit
Yes it was IEnumerable. I fell into the “all Wheres are created equal” trap.
Thanks all!

  • 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-30T15:19:15+00:00Added an answer on May 30, 2026 at 3:19 pm

    Have you tried just doing

    someList = someList.Where(exp.Compile());
    

    If someList is an IEnumerable you will need to use exp.Compile() which returns a Func<MyModel,bool>

    If someList is an IQueryable you can use exp.Compile() or you can use exp which is an Expression<Func<MyModel, bool>>

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

Sidebar

Related Questions

I was looking at the example in Microsoft KB318804 but they use the threadId
I am looking for a .NET JSON library that I can use to access
I'm looking for a dead simple example on how to use aggregate and calculate
I'm looking for a complete, step-by-step example of how to use jQuery Mobile 's
Looking at examples about socket programming, we can see that some people use AF_INET
im looking for an example script. I saw one yesterday but for the life
Ajax applications, and GWT in particular, use the URL fragment (e.g. http://example.com/myapp#fragment ) to
I was looking at a piece of code today and notice that this particular
I am currently looking at optimising an C# (.NET 3.5) application framework, and at
I am looking for a way to parse just a particular part of 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.