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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:56:49+00:00 2026-05-15T01:56:49+00:00

i have wrote a method that filters output with provided query and return it.

  • 0

i have wrote a method that filters output with provided query and return it. when one Where excuted; it return correct output but when more than one Where excuted; output is null and Exception occured with message “Enumeration yielded no results”. why? how i can fix it?

public IQueryable<SearchResult> PerformSearch(string query, int skip = 0, int take = 5)
    {
        if (!string.IsNullOrEmpty(query))
        {
            var queryList = query.Split('+').ToList();
            var results = GENERATERESULTS();
            string key;
            foreach (string _q in queryList)
            {
                if (_q.StartsWith("(") && _q.EndsWith(")"))
                {
                    key = _q.Replace("(", "").Replace(")", "");
                    results = results.Where(q => q.Title.Contains(key, StringComparison.CurrentCultureIgnoreCase));
                }
                else if (_q.StartsWith("\"") && _q.EndsWith("\""))
                {
                    key = _q.Replace("\"", "").Replace("\"", "");
                    results = results.Where(q => q.Title.Contains(key, StringComparison.CurrentCulture));
                }
                else if (_q.StartsWith("-(") && _q.EndsWith(")"))
                {
                    key = _q.Replace("-(", "").Replace(")", "");
                    results = results.Where(q=> !q.Title.Contains(key, StringComparison.CurrentCultureIgnoreCase));
                }
                else
                {
                    key = _q;
                    results = results.Where(q => q.Title.Contains(key, StringComparison.CurrentCulture));
                }
            }
            this._Count = results.Count();
            results = results.Skip(skip).Take(take);
            this._EndOn = DateTime.Now;
            this.ExecutionTime();
            return results;
        }
        else return null;
    }

thanks in advance 😉

  • 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-15T01:56:49+00:00Added an answer on May 15, 2026 at 1:56 am
            string key; 
            foreach (string _q in queryList) 
            { 
    

    Ah, the expression binds to the key variable. You need a new key variable for each execution of the loop.

            foreach (string _q in queryList) 
            { 
               string key; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Array i wrote a function MostFreq that takes an array of
I have a Python script I recently wrote that I call using the command
I have a macro that I wrote to just help me with my unit
I have several functions that I wrote and I use regularly on my servers,
I have a Windows Forms application that I wrote that does some monitoring of
I have a start of a webapp that I wrote without using the Object
I have several small open-source projects that I wrote. All my attempts to find
I have a groovy class that has the ability to write its output to
I have A method for format the output as JSON. My keyword_filter will be
I've written a class that implements IEnumerable<T> . I have a method that returns

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.