STX.EFCore.Client
2.0.0
dotnet add package STX.EFCore.Client --version 2.0.0
NuGet\Install-Package STX.EFCore.Client -Version 2.0.0
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="STX.EFCore.Client" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add STX.EFCore.Client --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: STX.EFCore.Client, 2.0.0"
#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 STX.EFCore.Client as a Cake Addin #addin nuget:?package=STX.EFCore.Client&version=2.0.0 // Install STX.EFCore.Client as a Cake Tool #tool nuget:?package=STX.EFCore.Client&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
STX.EFCore.Client
A Standard compliant client to wrap EF Core operations that can be used in a Storage Broker.
Main Features
- InsertAsync
- SelectAllAsync
- SelectAsync
- UpdateAsync
- DeleteAsync
- BulkInsertAsync
- BulkReadAsync
- BulkUpdateAsync
- BulkDeleteAsync
How do I use this?
Currently a storage broker looks something this:
public partial class StorageBroker : EFxceptionsContext, IStorageBroker
{
private readonly IConfiguration configuration;
public StorageBroker(IConfiguration configuration)
{
this.configuration = configuration;
this.Database.Migrate();
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
AddConfigurations(modelBuilder);
}
private static void AddConfigurations(ModelBuilder modelBuilder)
{
. . .
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
. . .
}
private async ValueTask<T> InsertAsync<T>(T @object)
where T : class
{
this.Entry(@object).State = EntityState.Added;
await this.SaveChangesAsync();
this.Entry(@object).State = EntityState.Detached;
return @object;
}
private async ValueTask<IQueryable<T>> SelectAllAsync<T>()
where T : class =>
this.Set<T>();
private async ValueTask<T> SelectAsync<T>(params object[] @objectIds)
where T : class =>
await this.FindAsync<T>(objectIds);
private async ValueTask<T> UpdateAsync<T>(T @object)
where T : class
{
this.Entry(@object).State = EntityState.Modified;
await this.SaveChangesAsync();
this.Entry(@object).State = EntityState.Detached;
return @object;
}
private async ValueTask<T> DeleteAsync<T>(T @object)
where T : class
{
this.Entry(@object).State = EntityState.Deleted;
await this.SaveChangesAsync();
this.Entry(@object).State = EntityState.Detached;
return @object;
}
}
With the client it will look like this and it addresses the sequencing issue that we currently have in brokers.
public partial class StorageBroker : EFxceptionsContext, IStorageBroker
{
private readonly IConfiguration configuration;
private readonly IEFCoreClient efCoreClient;
public StorageBroker(IConfiguration configuration)
{
this.configuration = configuration;
this.Database.Migrate();
this.efCoreClient = new EFCoreClient(this);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
AddConfigurations(modelBuilder);
}
private static void AddConfigurations(ModelBuilder modelBuilder)
{
. . .
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
. . .
}
private async ValueTask<T> InsertAsync<T>(T @object) where T : class =>
await efCoreClient.InsertAsync(@object);
private async ValueTask<IQueryable<T>> SelectAllAsync<T>() where T : class =>
await efCoreClient.SelectAllAsync<T>();
private async ValueTask<T> SelectAsync<T>(params object[] @objectIds) where T : class =>
await efCoreClient.SelectAsync<T>(@objectIds);
private async ValueTask<T> UpdateAsync<T>(T @object) where T : class =>
await efCoreClient.UpdateAsync(@object);
private async ValueTask<T> DeleteAsync<T>(T @object) where T : class =>
await efCoreClient.DeleteAsync(@object);
private async ValueTask BulkInsertAsync<T>(IEnumerable<T> objects) where T : class =>
await efCoreClient.BulkInsertAsync<T>(objects);
private async ValueTask BulkReadAsync<T>(IEnumerable<T> objects) where T : class =>
await efCoreClient.BulkReadAsync<T>(objects);
private async ValueTask BulkUpdateAsync<T>(IEnumerable<T> objects) where T : class =>
await efCoreClient.BulkUpdateAsync<T>(objects);
private async ValueTask BulkDeleteAsync<T>(IEnumerable<T> objects) where T : class =>
await efCoreClient.BulkDeleteAsync<T>(objects);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.EntityFrameworkCore (>= 9.0.0)
-
net9.0
- Microsoft.EntityFrameworkCore (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Upgrade to .NET 9.0 and EF Core 9.0