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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:24:24+00:00 2026-06-18T09:24:24+00:00

This might be a badly worded question for what I’m trying to learn so

  • 0

This might be a badly worded question for what I’m trying to learn so I’ll explain what I am trying to do. I have the following list being created using the following expression:

var showIndexes = from item in lItems
                               where WildcardString.IsMatch(item.RecordId.ToString(), filter) ||
                                     WildcardString.IsMatch(item.Tokens.ToString(), filter) ||
                                     WildcardString.IsMatch(string.Format("{0}:{1}", item.OwnerID.SystemName, item.OwnerID.Port.ToString()), filter) ||
                                     WildcardString.IsMatch(item.ChildID.UserName, filter) ||
                                     WildcardString.IsMatch(item.TypeOfLicense.ToString(), filter) ||
                                     WildcardString.IsMatch(item.ExpiryTime.DateTime.ToLocalTime().ToString(), filter)
                               select item.RecordId.ToString();

I want to put this expression into a function, and pass in constrainments used in the “where” in as a single parameter. How do I achieve this? I’ve seen similar functionality using the bitwise OR when working with file attributes (when you select different attribute enums) so I believe it should be possible to write my own function which takes a group of delegates as the “where” rule.

If it is relevant, WildcardString.IsMatch(string, string) is a boolean function. Also, I have three different functions performing the exact same thing but on different lists, which is why I’d like to learn how to do reduce this to a single function, and just pass the list and the selection rules in.

  • 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-18T09:24:25+00:00Added an answer on June 18, 2026 at 9:24 am

    Simply define a predicate: a function that takes an item and returns a boolean.

    Assuming that item is of type Record and that filter is in scope:

    Func<Record, bool> predicate = r =>
        WildCardString.IsMatch(r.RecordId.ToString(), filter) ||
        WildCardString.IsMatch(...);
    

    You can then treat predicate as a first-class value (store it, pass it as a parameter, etc) and filter any IEnumerable<Record> with

    var filtered = enumerable.Where(predicate);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might sound like a stupid question but just trying to learn something here.
This might be a naive question. However, I am just trying to understand why
This might sound rudimentary but, I have created tables by running queries in Workbench
This might be a stupid question, but although I have a few projects now
This might be a duplicate question as I have found a few that are
This might be a noob question. Actually I am trying to toggle the Activity
This might seem like a very easy question for some of you folks, but
This might be a simple question but I've searched and searched and can't find
This might be a very basic question but it confuses me. Can two different
This might get a little confusing as I have tried everything to make this

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.