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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:51:52+00:00 2026-06-06T19:51:52+00:00

Quick question about using IQueryable objects. Can I do something like that and if

  • 0

Quick question about using IQueryable objects. Can I do something like that and if not – what is the alternative way?

IQueryable<Item> q = this.ObjectContext.items;

q = q.Where(i => i.price > 100);

...

q = q.Where(i => i.class_name.Contain("apple"));

Update: Here is full code of my function (may be I’m missing something):

public IQueryable<item> Getitem(string filter)
{
    // filtering by user departments
    IQueryable<item> pre_q = from t_item in this.ObjectContext.items
        join t_useritems in this.ObjectContext.user_to_item on
        t_item.number equals t_useritems.number
        where t_useritems.user_name == this.userName
        select t_item;

    if (filter != null)
    {
        QueryFilter qf = new QueryFilter(filter);
        string _excludeClass = qf.GetPropertyValueByName("excludeClass");
        string _excludeSubcat = qf.GetPropertyValueByName("excludeSubcat");
        string _searchBy = qf.GetPropertyValueByName("searchby");
        string _search = qf.GetPropertyValueByName("search");

        if (!string.IsNullOrEmpty(_excludeClass))
            pre_q = pre_q.Where(i => i.class_name != _excludeClass);

        if (!string.IsNullOrEmpty(_excludeSubcat))
            pre_q = pre_q.Where(i => i.subcat_name != _excludeSubcat);

        if (!string.IsNullOrEmpty(_searchBy) && !string.IsNullOrEmpty(_search))
        {
            if (_searchBy == "number")
                pre_q = pre_q.Where(i => i.number.Contains(_search));
            else if (_searchBy == "description")
                pre_q = pre_q.Where(i => i.description.Contains(_search));
            else if (_searchBy == "class_name")
                pre_q = pre_q.Where(i => i.class_name.Contains(_search));
            else if (_searchBy == "cat_name")
                pre_q = pre_q.Where(i => i.cat_name.Contains(_search));
            else if (_searchBy == "subcat_name")
                pre_q = pre_q.Where(i => i.subcat_name.Contains(_search));
            else if (_searchBy == "all_fields")
                pre_q = pre_q.Where(i => i.number.Contains(_search) ||
                  i.description.Contains(_search) ||
                  i.class_name.Contains(_search) ||
                  i.cat_name.Contains(_search) ||
                  i.subcat_name.Contains(_search));
            }
        }
    }
    return pre_q.OrderBy(i => i.number);
}

Essentially what’s happening – I pass excludeClass filter and some search text filter. After applying excludeClass I can see that number of records is correct, however when I after apply search filter – it basically reset already filtered items and they are getting back in the result.

  • 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-06T19:51:54+00:00Added an answer on June 6, 2026 at 7:51 pm

    Yes, you can. IQueryable<T> is “composable”. That’s fine. It will only evaluate the final composed query when you do something that needs the data, for example a ToList(), a foreach, or an aggregate such as Count(), Max(), etc. That pattern is pretty much how a lot of multi-field search screens work.

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

Sidebar

Related Questions

Just a quick question about a function like this: class Test { public: Test(vector<int>&
quick question about using ORMLite. I am trying to make sure that my implementation
Just a quick question about using select() . I'm using select() to read from
I am using native C++ with VSTS 2008. A quick question about virtual function.
Quick question about JavaScript event objects - how does JavaScript know when I'm trying
Quick question about include/requre_once . I have some code that is common to a
I have a quick question about something I imagine must be pretty easy -
Have a quick question about what would be the best way to implement iterators
A quick question involving PHP development, I seem to be wondering about this more
Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I'm

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.