Git Product home page Git Product logo

extensions's Introduction

IQueryable Search Extension

This is a C# extension method that allows you to perform a search operation on a collection of objects represented by IQueryable<T>. The search is performed based on specific properties of the objects.

Usage

  1. Add the Extensions Class to Your Project: Copy the provided Extensions class into your C# project.

  2. Using the Extension Method:

    using AveryBusiness;
    using System.Linq;
    
    // Your IQueryable<T> source
    IQueryable<YourType> source = ...;
    
    // Define search parameters
    string searchQuery = "YourSearchQuery";
    string[] searchParameters = { "Property1", "Property2.NestedProperty" }; // Properties to search
    
    // Perform the search
    var result = source.Search(searchQuery, searchParameters).ToList();

    Replace YourType, "Property1", "Property2.NestedProperty", and "YourSearchQuery" with appropriate types, property names, and search query.

Parameters

  • source: The IQueryable<T> representing the collection of objects to search within.
  • search: The string to search for within the specified properties.
  • parameters: An array of strings representing the names of the properties to search within. Nested properties can be specified using dot notation (e.g., "Property1.NestedProperty").

How It Works

The extension method Search<TSource>() dynamically generates a predicate expression based on the search query and properties specified. It builds an expression tree that represents the search condition and applies it to filter the IQueryable<T> source.

The method SearchPredicate<T>() generates the main predicate expression, while PredicateFromProperties<T>() creates individual expressions for each property specified in the search parameters.

extensions's People

Contributors

scott-avery-gnmh avatar averybusinesssolutions avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.