STX.EFCore.Client 0.0.0.3

dotnet add package STX.EFCore.Client --version 0.0.0.3                
NuGet\Install-Package STX.EFCore.Client -Version 0.0.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="STX.EFCore.Client" Version="0.0.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add STX.EFCore.Client --version 0.0.0.3                
#r "nuget: STX.EFCore.Client, 0.0.0.3"                
#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=0.0.0.3

// Install STX.EFCore.Client as a Cake Tool
#tool nuget:?package=STX.EFCore.Client&version=0.0.0.3                

STX.EFCore.Client

A Standard compliant client to wrap EF Core operations that can be used in a Storage Broker. This includes bulk operations from the popular Entity Framework Extensions for EF Core library. (Z.EntityFramework.Extensions.EFCore)

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 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. 
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
0.0.0.3 35 10/4/2024
0.0.0.2 45 10/2/2024
0.0.0.1 38 10/2/2024

Initial release of the client.