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

  • Home
  • SEARCH
  • 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 6541285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:05:12+00:00 2026-05-25T11:05:12+00:00

I am trying to modify some open source code to change how it filters

  • 0

I am trying to modify some open source code to change how it filters search results. I want to query by the ‘name’ of a record instead of it’s key. (I have records with duplicate names I want to pull back, but different keys.)

This pulls back all the records

 public static IEnumerable<ticket> GetTickets(stDataContext db, bool? active)
    {
        return from p in db.tickets
               where
                   (active == null ? true :
                   ((bool)active ? p.active : !p.active))
               select p;
    }

The next level up in the code queries against this return by the ID key. I’m not sure which place I should modify.

 public static IEnumerable<ticket> Search(stDataContext db, string[] keywords, int usr, DateTime dtFrom, DateTime dtTo, int prty, int stat, bool onlyOpen, int grp, int subgrp,string subgroupName, bool? active)
    {
        return from p in GetTickets(db, active)
               where
                   p.title.ToLower().Contains(keywords[0].ToLower()) &&
                   p.title.ToLower().Contains(keywords[1].ToLower()) &&
                   p.title.ToLower().Contains(keywords[2].ToLower()) &&
                   p.title.ToLower().Contains(keywords[3].ToLower()) &&
                   p.title.ToLower().Contains(keywords[4].ToLower()) &&
                   p.title.ToLower().Contains(keywords[5].ToLower()) &&
                   p.title.ToLower().Contains(keywords[6].ToLower()) &&
                   p.title.ToLower().Contains(keywords[7].ToLower()) &&
                   p.title.ToLower().Contains(keywords[8].ToLower()) &&
                   p.title.ToLower().Contains(keywords[9].ToLower()) &&

                   p.submitter == (usr < 0 ? p.submitter : usr) &&
                   p.submitted >= dtFrom &&
                   p.submitted <= dtTo &&
                   (prty == 0 ? true : p.priority == prty) &&
                   (stat == 0 ? true : p.ticket_status == stat) &&
                   (!onlyOpen ? true : p.ticket_status != 5) &&
                   (grp == 0 ? true : (
                   (p.sub_unit2.unit_ref == grp) ||
                   (p.sub_unit.unit_ref == grp))) &&
                   (subgrp == 0 ? true : (
                   (p.originating_group == subgrp) ||
                   (p.assigned_to_group == subgrp)))
               select p;
    }

The last 2 lines of the where cause are the ones I want to change. Instead of using the fkey (p.originating_group,p.assigned_to_group, and subgrp) I want to use the name subgroupName.

Should I filter the records by the subgroup in GetTickets method or at the Search method and how do I add a subquery to the linq?

Thanks,
Tim

  • 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-25T11:05:12+00:00Added an answer on May 25, 2026 at 11:05 am

    instead of directly returning the results there, store the query in a variable

    var query = from p in GetTickets(db, active)
                   where...
    

    then you can apply other criteria to that query

    return from c in query
           where...//aply additional criteria here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to modify some code that returns results from the database. Currently the
I am trying to modify the output stream to search/replace some XHTML tags returned
I'm trying to compile code from an open source project, and I'm running into
Our development uses lots of open-source code and I'm trying to figure out what
I'm trying to modify some legacy ASP classic code, and I don't know much
I'm currently trying to modify some HttpWebRequest functions, but I can't do it through
I'm trying to determine how to modify SAP R/3 package code of an installed
I need some help with jQuery syntax. I'm trying to modify the opacity effect
I'm trying to read some text from an html file, modify it in a
I m trying to modify some C++ files in ns2 and then recompile using

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.