SqlKata.EntityFrameworkCore 1.0.3

.NET 6.0
dotnet add package SqlKata.EntityFrameworkCore --version 1.0.3
NuGet\Install-Package SqlKata.EntityFrameworkCore -Version 1.0.3
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="SqlKata.EntityFrameworkCore" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SqlKata.EntityFrameworkCore --version 1.0.3
#r "nuget: SqlKata.EntityFrameworkCore, 1.0.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SqlKata.EntityFrameworkCore as a Cake Addin
#addin nuget:?package=SqlKata.EntityFrameworkCore&version=1.0.3

// Install SqlKata.EntityFrameworkCore as a Cake Tool
#tool nuget:?package=SqlKata.EntityFrameworkCore&version=1.0.3

SqlKata.EntityFrameworkCore SqlKata.EntityFrameworkCore SqlKata.EntityFrameworkCore

.NET library that aims to facilitate the combination of DbContexts (EntityFrameworkCore) and SqlKata queries.

Installation

PM> Install-Package SqlKata.EntityFrameworkCore

Example

using SqlKata;
using SqlKata.Compilers;
using SqlKata.EntityFrameworkCore;


using var Db = new MyDbContext();

// Set the compiler.
SqlKataEntityFramework.SetDefaultCompiler(new MySqlCompiler());

// Example 1
var BerkanLogins = Db.UsersLogins.FromSqlKata(
	Query => Query.From("users_logins").Where("user_id", 1).Limit(0).OrderByDesc("id")).ToList();
Console.WriteLine($"BerkanLogins: Admin logged in {BerkanLogins.Count} times, last login from {BerkanLogins.FirstOrDefault()?.IpAddress}");

// Example 2
var UserLogin2 = Db.UsersLogins.FromSqlKata(new Query("users_logins")
	.Where("user_id", "6")
	.Limit(1))
	.FirstOrDefault();
Console.WriteLine($"UserLogin2: {UserLogin2?.IpAddress}");

// Example 3 - Executing commands
var LoginsDeleted = Db.Database.ExecuteSqlKata(new Query("users_logins")
	.Where("ip_address", "LIKE", "127.0.0.1")
	.OrderBy("id")
	.AsDelete());
Console.WriteLine($"{LoginsDeleted} logins were deleted!");

// Example 4 - Executing commands
var RowsUpdated = Db.Database.ExecuteSqlKata(new Query("users_groups_links")
	.AsUpdate(new { user_group_id = 7 })
	.Where("user_id", 1)
	.Where("user_group_id", 6));
Console.WriteLine($"{RowsUpdated} rows were affected!");

License

You are free to use this library however you or your company wants to.

Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
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.3 185 9/18/2022
1.0.2 237 5/9/2022
1.0.1 140 5/9/2022
1.0.0 145 5/9/2022