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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:46:44+00:00 2026-06-16T23:46:44+00:00

Firstly, as a general overview of the problem, I am writing an MVC web

  • 0

Firstly, as a general overview of the problem, I am writing an MVC web application in that needs to query my repository based upon several different business logic rules. The user will first enter text into the webpage, and said text will be parsed in my business layer and the appropriate where clause query will be sent to the repository.

So, for an example of my code:

public Document GetDocuments(string txtFilter)
{
    string [] filterVals = // do some business logic here to parse txtFilter into the filterValsArray

    // filterQuery will utlimately contain the where clause for the repository
    Expression<Func<DocumentListViewModel, bool>> filterQuery = null;

    // case 1, when filterVals has only 1 value:
    if (filterVals[0].Length == 1)
    {
        filterQuery = x => x.SomeField == filterVals[0];
    }
    else // assign filterQuery to another set of expressions

    // repository call
    return _unitOfWork.DocumentRepository.Get(filterQuery);
}

When I run this, I get an run-time exception ” Cannot invoke a non-delegate type.” What I believe is happening (and of course correct me if I’m wrong about this), is that the actual expression is enumerated in the repository, at which point filterVals is no longer in scope. So… is there a way to get these values into my where clause expressions? Any help would be greatly appreciated.

  • 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-06-16T23:46:45+00:00Added an answer on June 16, 2026 at 11:46 pm

    Try changing

        Expression<Func<DocumentListViewModel, bool>> filterQuery = null;
    

    to

        Func<DocumentListViewModel, bool> filterQuery = null;
    

    and see what happens.

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

Sidebar

Related Questions

Firstly sorry, I'm a really big beginner. I ran into a problem that I
Firstly, this is going to sound like homework, but it ain't. Just a problem
Firstly: I get the mvc and php of magento, but I'm not fully versed
Firstly, I have created a custom list definition based on the Tasks list in
Firstly, I have migrated my CVS repository into SVN repository. I checked out this
Firstly, I'm in C# here so that's the flavor of RegEx I'm dealing with.
Firstly I must emphasis that the HTML is pre-generated and cannot be altered -
Firstly, I am most comfortable coding in Java. I am creating an application in
I am after a general purpose unspecialised plain text file extractor. Firstly before people
I am very new to Ruby, and programming in general. Firstly, I have the

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.