/** * CustomQueryBuilder implements the Builder Pattern with Fluent Interface for constructing * complex database queries in a readable and chainable manner. * * This class provides a fluent API that allows method chaining to build queries step by step, * making the code more readable and maintainable. It follows the builder pattern where each * method returns the builder instance to enable continuous method chaining. * * Usage Pattern: * CustomQueryBuilder.Create(source) * .Init(query) * .SearchFilter(searchTerm, columns) * .CustomSorting(sortField, sortOrder) * .Build(); * * Key Features: * - Fluent Interface: All configuration methods return 'this' for method chaining * - Builder Pattern: Constructs complex queries through a series of method calls * - Immutable Building: Each method adds configuration without breaking the chain * - Terminal Operations: Final methods like Build() return the constructed query * * Method Summaries: * * Create(IQueryable<Object> source) * - Static factory method that initializes a new builder instance * - Sets the base query source and returns builder for chaining * - Entry point for the fluent interface * * Init(IQueryable<Object> source) * - Initializes or reinitializes the query source * - Returns builder instance for method chaining * - Optional if Create() already set the source * * SearchFilter(String search, List<String> columns) * - Applies search filtering logic to the query * - Filters results based on search term across specified columns * - Returns builder instance for continued chaining * * CustomSorting(String sort, String order) * - Applies sorting logic to the query * - Sorts results by specified field in given order (ASC/DESC) * - Returns builder instance for continued chaining * * Build() * - Terminal method that returns the final constructed query * - Completes the building process and provides the IQueryable result * - Should be called at the end of the method chain * * GetQuery() * - Alternative terminal method to retrieve the constructed query * - Similar to Build() but may include additional processing * - Returns the final IQueryable object for execution */