CC.EFCore.Extensions 1.0.1

dotnet add package CC.EFCore.Extensions --version 1.0.1                
NuGet\Install-Package CC.EFCore.Extensions -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CC.EFCore.Extensions" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CC.EFCore.Extensions --version 1.0.1                
#r "nuget: CC.EFCore.Extensions, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CC.EFCore.Extensions as a Cake Addin
#addin nuget:?package=CC.EFCore.Extensions&version=1.0.1

// Install CC.EFCore.Extensions as a Cake Tool
#tool nuget:?package=CC.EFCore.Extensions&version=1.0.1                

efcore-extensions

Nuget Nuget

some business logic extension with efcore

Usage

dotnet add package CC.EFCore.Extensions

PageQuery

var pageStudents = await appDbContext.Set<Student>().QueryPageAsync(new PageQueryRequest()
{
	Page = 1,
	Count = 10
});

var students = pageStudents.Data;
var total = pageStudents.Total;
var page = pageStudents.Page;
var count = pageStudents.Count;


// map to dto in database execute sql
await appDbContext.Set<Student>().QueryPageAsync(new PageQueryRequest()
{
	Page = 1,
	Count = 10
},dbSelector:s => new {
	s.Id, s.FirstName, s.LastName, s.Age
});

// map to dto after databse execute sql
await appDbContext.Set<Student>().QueryPageAsync(new PageQueryRequest()
{
	Page = 1,
	Count = 10
},dbSelector:s => {
	var fullName = $"{s.FirstName} {s.LastName}";
	return new { s.Id, Name=fullName , s.Age };
});

WhereIf


List<Student> QueryStudent(int? minAge) =>
appDbContext.Set<Student>()
	.WhereIf(minAge != null, s => s.Age > minAge.Value)
	.ToList();

WhereIfNotNull


List<Student> QueryStudent(int? minAge) =>
appDbContext.Set<Student>()
	.WhereIfNotNull(minAge, age=> s => s.Age > age)
	.ToList();

OrderByDefaultDesc


List<Student> QueryStudentOrderByAge(bool? desc) =>
appDbContext.Set<Student>()
	.OrderByDefaultDesc(s => s.Age, desc)
	.ToList();

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 492 6/30/2023
1.0.0 493 6/20/2023