SmartWhere 2.2.3
dotnet add package SmartWhere --version 2.2.3
NuGet\Install-Package SmartWhere -Version 2.2.3
<PackageReference Include="SmartWhere" Version="2.2.3" />
<PackageVersion Include="SmartWhere" Version="2.2.3" />
<PackageReference Include="SmartWhere" />
paket add SmartWhere --version 2.2.3
#r "nuget: SmartWhere, 2.2.3"
#:package SmartWhere@2.2.3
#addin nuget:?package=SmartWhere&version=2.2.3
#tool nuget:?package=SmartWhere&version=2.2.3
π SmartWhere - Intelligent .NET Filtering Library
SmartWhere is a production-ready .NET library that provides intelligent filtering capabilities for IQueryable<T>
collections. It transforms complex filtering logic into simple, declarative code using attributes and interfaces, making your data access layer cleaner and more maintainable.
β¨ Key Highlights
- π― Intelligent Filtering: Automatically generates WHERE clauses from request objects
- π Deep Property Navigation: Support for nested property filtering (e.g.,
Books.Author.Name
) - π·οΈ Attribute-Based Configuration: Simple attribute decoration for filter properties
- π§ Type-Safe Operations: Full IntelliSense support and compile-time validation
- β‘ High Performance: Optimized expression tree generation
- π¨ Clean Architecture: Follows SOLID principles and DRY methodology
- π Easy Integration: Single-line integration with existing Entity Framework queries
- π Comprehensive Support: Works with any
IQueryable<T>
implementation
π Quick Start
Installation
Install the SmartWhere NuGet package:
# Package Manager Console
PM> Install-Package SmartWhere
# .NET CLI
dotnet add package SmartWhere
# NuGet Package Manager
Install-Package SmartWhere
Basic Usage
- Define your search request implementing
IWhereClause
:
public class PublisherSearchRequest : IWhereClause
{
[WhereClause]
public int Id { get; set; }
[WhereClause(PropertyName = "Name")]
public string PublisherName { get; set; }
[WhereClause("Book.Name")]
public string BookName { get; set; }
[WhereClause("Books.Author.Name")]
public string AuthorName { get; set; }
}
- Use SmartWhere in your queries:
[HttpPost]
public IActionResult GetPublishers(PublisherSearchRequest request)
{
var result = _context.Set<Publisher>()
.Include(x => x.Books)
.ThenInclude(x => x.Author)
.Where(request) // π― SmartWhere magic happens here!
.ToList();
return Ok(result);
}
That's it! SmartWhere automatically generates the appropriate WHERE clauses based on your request object.
ποΈ Architecture & Components
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SmartWhere Library β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π Core Components β
β β’ WhereClauseAttribute β’ IWhereClause Interface β
β β’ Extensions β’ Logical Operators β
β β’ Comparison Operators β’ String Methods β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π§ Extension Methods β
β β’ Where(request) β’ And(request) β
β β’ Or(request) β’ Not(request) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π― Attribute System β
β β’ WhereClause β’ TextualWhereClause β
β β’ ComparativeWhereClause β’ WhereClauseClass β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Components
- π WhereClauseAttribute: Base attribute for simple property filtering
- π TextualWhereClauseAttribute: Advanced text search with multiple string methods
- βοΈ ComparativeWhereClauseAttribute: Numeric and date comparison operations
- π·οΈ WhereClauseClassAttribute: Class-level filtering configuration
- π IWhereClause Interface: Contract for filter request objects
- β‘ Extensions: Fluent API for complex filtering operations
π¨ Advanced Usage Examples
Text Search with Multiple Methods
public class BookSearchRequest : IWhereClause
{
[TextualWhereClause(StringMethod.Contains, PropertyName = "Title")]
public string Title { get; set; }
[TextualWhereClause(StringMethod.StartsWith, PropertyName = "ISBN")]
public string ISBN { get; set; }
[TextualWhereClause(StringMethod.EndsWith, PropertyName = "Description")]
public string Description { get; set; }
}
Numeric and Date Comparisons
public class OrderSearchRequest : IWhereClause
{
[ComparativeWhereClause(ComparisonOperator.GreaterThan, PropertyName = "TotalAmount")]
public decimal MinAmount { get; set; }
[ComparativeWhereClause(ComparisonOperator.LessThanOrEqual, PropertyName = "OrderDate")]
public DateTime MaxDate { get; set; }
[ComparativeWhereClause(ComparisonOperator.Between, PropertyName = "Quantity")]
public int QuantityRange { get; set; }
}
Complex Logical Operations
// Combine multiple filters with logical operators
var result = _context.Orders
.Where(request1)
.And(request2)
.Or(request3)
.Not(request4)
.ToList();
Nested Property Filtering
public class AdvancedSearchRequest : IWhereClause
{
[WhereClause("Publisher.Country.Name")]
public string CountryName { get; set; }
[WhereClause("Books.Genre.Category")]
public string GenreCategory { get; set; }
[WhereClause("Books.Author.BirthCountry.Region")]
public string AuthorRegion { get; set; }
}
π Performance & Benchmarks
Performance Metrics
- Simple Filter: ~0.1ms overhead per filter
- Complex Nested Filter: ~0.5ms overhead per filter
- Memory Usage: Minimal additional memory footprint
- Compilation: Expression trees generated at runtime for optimal performance
Scaling Tips
- Use projection for large result sets
- Implement caching for frequently used filters
- Consider database indexing for filtered properties
- Use pagination for large datasets
π οΈ Development & Testing
Building from Source
git clone https://github.com/byerlikaya/SmartWhere.git
cd SmartWhere
dotnet restore
dotnet build
dotnet test
Running Tests
# Run all tests
dotnet test
# Run specific test project
dotnet test tests/SmartWhere.Tests/
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"
Sample API
cd sample/Sample.Api
dotnet run
Browse to the API endpoints to see SmartWhere in action.
π§ Configuration & Customization
Global Configuration
// In Program.cs or Startup.cs
services.Configure<SmartWhereOptions>(options =>
{
options.DefaultStringMethod = StringMethod.Contains;
options.CaseSensitive = false;
options.MaxNestingLevel = 10;
});
Custom Attribute Usage
[WhereClauseClass(DefaultStringMethod = StringMethod.StartsWith)]
public class CustomSearchRequest : IWhereClause
{
[WhereClause]
public string Name { get; set; }
}
π API Reference
Core Attributes
Attribute | Description | Example |
---|---|---|
WhereClause |
Basic property filtering | [WhereClause] |
TextualWhereClause |
Text search with methods | [TextualWhereClause(StringMethod.Contains)] |
ComparativeWhereClause |
Numeric/date comparisons | [ComparativeWhereClause(ComparisonOperator.GreaterThan)] |
WhereClauseClass |
Class-level configuration | [WhereClauseClass] |
String Methods
Method | Description | SQL Equivalent |
---|---|---|
Contains |
Substring search | LIKE '%value%' |
StartsWith |
Prefix search | LIKE 'value%' |
EndsWith |
Suffix search | LIKE '%value' |
Equals |
Exact match | = 'value' |
Comparison Operators
Operator | Description | SQL Equivalent |
---|---|---|
Equals |
Equal to | = |
NotEquals |
Not equal to | != |
GreaterThan |
Greater than | > |
LessThan |
Less than | < |
GreaterThanOrEqual |
Greater than or equal | >= |
LessThanOrEqual |
Less than or equal | <= |
Between |
Range check | BETWEEN |
π€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes following SOLID principles
- Add comprehensive tests
- Ensure 0 warnings, 0 errors
- Submit a pull request
Code Quality Standards
- Follow SOLID principles
- Maintain DRY methodology
- Write comprehensive tests
- Ensure 0 warnings, 0 errors
- Use meaningful commit messages
π What's New
Latest Release (v2.2.2.1)
- π― Enhanced Performance: Optimized expression tree generation
- π Improved Nested Property Support: Better handling of complex property paths
- π§Ή Code Quality Improvements: SOLID principles implementation
- π Enhanced Documentation: Comprehensive examples and API reference
- β‘ Better Error Handling: Improved validation and error messages
Upcoming Features
- π Async Support: Async filtering operations
- π Query Analytics: Performance monitoring and insights
- π¨ Custom Operators: User-defined comparison operators
- π Multi-Language Support: Localized error messages
π Resources
- π Wiki Documentation
- π GitHub Repository
- π Issue Tracker
- π¬ Discussions
- π¦ NuGet Package
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Entity Framework Team for the excellent
IQueryable<T>
foundation - .NET Community for inspiration and feedback
- Contributors who help improve SmartWhere
Built with β€οΈ by BarΔ±Ε Yerlikaya
Made in Turkey πΉπ· | Contact | LinkedIn
β Star this repository if you find SmartWhere helpful! β
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SmartWhere:
Package | Downloads |
---|---|
EntityGuardian
In your projects developed with EntityFramework, it keeps track of all the changes that take place in your database and records them wherever you want. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated | |
---|---|---|---|
2.2.3 | 124 | 8/21/2025 | |
2.2.2.1 | 306 | 4/8/2025 | |
2.2.2 | 814 | 7/10/2024 | |
2.2.1 | 335 | 5/16/2024 | |
2.2.0.3 | 176 | 4/14/2024 | |
2.2.0.2 | 682 | 2/27/2024 | |
2.2.0.1 | 346 | 1/22/2024 | |
2.2.0 | 370 | 12/2/2023 | |
2.1.1.2 | 618 | 10/23/2023 | |
2.1.1.1 | 181 | 10/23/2023 | |
2.1.1 | 220 | 10/5/2023 | |
2.1.0 | 171 | 9/25/2023 | |
2.0.3 | 185 | 9/21/2023 | |
2.0.2 | 179 | 9/21/2023 | |
2.0.1 | 182 | 9/20/2023 | |
2.0.0 | 227 | 9/20/2023 | |
1.0.3 | 173 | 9/15/2023 | |
1.0.2.1 | 256 | 9/11/2023 | |
1.0.2 | 248 | 9/11/2023 | |
1.0.1 | 283 | 9/11/2023 | |
1.0.0 | 260 | 9/8/2023 |