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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:20:39+00:00 2026-06-14T22:20:39+00:00

I am using a common function for filtering a list of records. the function

  • 0

I am using a common function for filtering a list of records.

the function is below:

  class FilterRecords
{

    public static object ParseExpression(string Condition, string FilterColumn)
    {
        string _operator = "";
        string _condition = "";                       

        if (Condition.Substring(0, 1) == "<" || Condition.Substring(0, 1) == ">")
        {
            _operator = Condition.Substring(0, 1);

            if (Condition.Substring(1, 1) == "=")
            {
                _operator += "=";
                _condition = Condition.Substring(2);
            }
            else
            {
                _condition = Condition.Substring(1);
            }
            _operator = "=";
            return (dbContext.OrdsRlsds.AsQueryable().Where(FilterColumn + " " + _operator + " " + " @0", _condition).ToList());
        }
        else
        {
            if (Condition.Contains(','))
            {
                string[] conds = Condition.Split(',');
                return (dbContext.OrdsRlsds.AsQueryable().Where(FilterColumn + " >= @0 && " + FilterColumn + " <= @1", conds).ToList());

            }
            else
            {
                return (dbContext.OrdsRlsds.AsQueryable().Where(FilterColumn + " == @0", Condition).ToList());
            }
        }
    }
}

This function uses dynamic query library. At the moment, it filters only one type of records – OrdsRlsds. I need to make this a generic filter so that I can pass any collection and then get the filtered results back.

  • 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-14T22:20:41+00:00Added an answer on June 14, 2026 at 10:20 pm

    Are you using Entity Framework? If so then could you do something like this with generics?

    public static IList<T> ParseExpression<T>(string Condition, string FilterColumn) where T:class
    {
      var query = dbContext
                  .CreateObjectSet<T>()
                  .AsQueryable();
    
      //add filters etc.
    
      return query.ToList();
    }
    

    You would then have to pass the required entity type as a type argument to your method like this:

    FilterRecords.ParseExpression<OrdsRlsd>(condition, filterColumn);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Apache Common Logging in Desktop Application. private static final Log log
What is the common usage of using ant to execute a java class or
I need to write a common sort function. I am using jQuery for sorting.
I'm using SLIME to debug my Common Lisp function. Inside the function, I've made
The Dropdownlist data binding using throw common function. In this have a problem in
I am trying to write a common Save function and I am using Dbcommand
i have several controllers which will all be using common functionality. So i have
I'd like to be able to define lambdas using common Lisp syntax, in Clojure.
Basically, I'd like to do the following, only using Common Lisp instead of Python:
I'm trying to read the contents of a small text file using the common

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.