Yozian.Extension
1.0.0
See the version list below for details.
dotnet add package Yozian.Extension --version 1.0.0
NuGet\Install-Package Yozian.Extension -Version 1.0.0
<PackageReference Include="Yozian.Extension" Version="1.0.0" />
paket add Yozian.Extension --version 1.0.0
#r "nuget: Yozian.Extension, 1.0.0"
// Install Yozian.Extension as a Cake Addin #addin nuget:?package=Yozian.Extension&version=1.0.0 // Install Yozian.Extension as a Cake Tool #tool nuget:?package=Yozian.Extension&version=1.0.0
Useful Extension methods
Currently wiki is under working, you could take a look into test project to get examples.
Type Decorated
- Exception
- Expression
- ICollection
- IDicationary
- IEnumerable
- IQueryable
- Object
- String
Take IQueryable Extension method as example
conditional query where closure
The example shows the extension method WhereWhen
eliminate if statement block.
The constrain applied only when the condition matched, so that you could achieve dynamic query easily!
var books = await this.dbContext.Book
.Where(x => x.Name.Equals(request.Name))
.WhereWhen(
!string.IsNullOrEmpty(request.Category),
x => x.Category.Equals(request.Category)
)
.WhereWhen(
request.PublishDate.HasValue,
x => x.PublishDate.Equals(request.PublishDate)
)
.ToListAsync();
for old school way, would have lots of if statement block
var query = this.dbContext.Book
.Where(x => x.Name.Equals(request.Name));
if(!string.IsNullOrEmpty(request.Category)){
query = query.Where(x => x.Category.Equals(request.Category))
}
if(request.PublishDate.HasValue){
query = query.Where(x => x.PublishDate.Equals(request.PublishDate))
}
var books = await query.ToListAsync();
feel free for pull request
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. |
.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 was computed. |
.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.Library (>= 2.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Yozian.Extension:
Package | Downloads |
---|---|
Yozian.DependencyInjectionPlus
Easy for DI register, Auto register services, Decorate service with attribute |
|
Yozian.EFCorePlus
partial updated and scheam description scripts generation |
|
Yozian.Validation
fluent strong type validation |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.6.3 | 37 | 11/27/2024 |
2.6.1 | 188 | 11/8/2024 |
2.5.0 | 312 | 11/16/2023 |
2.4.0 | 2,473 | 4/16/2022 |
2.3.0 | 427 | 3/25/2022 |
2.3.0-preview | 178 | 3/25/2022 |
2.2.7 | 676 | 3/30/2021 |
2.2.6 | 321 | 3/22/2021 |
2.2.4 | 394 | 3/11/2021 |
2.2.2 | 345 | 3/11/2021 |
2.2.2-preview | 228 | 3/11/2021 |
2.2.1 | 572 | 3/8/2020 |
2.2.0 | 484 | 2/6/2020 |
2.1.3 | 461 | 12/22/2019 |
2.1.1 | 882 | 1/21/2019 |
2.1.0 | 862 | 1/16/2019 |
2.0.1 | 1,157 | 1/14/2019 |
2.0.0 | 5,362 | 1/13/2019 |
1.0.1 | 838 | 1/10/2019 |
1.0.0 | 1,998 | 1/9/2019 |