Temelie.Repository 1.0.206

This package has a SemVer 2.0.0 package version: 1.0.206+b1e6d6f.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Temelie.Repository --version 1.0.206
                    
NuGet\Install-Package Temelie.Repository -Version 1.0.206
                    
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="Temelie.Repository" Version="1.0.206" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Temelie.Repository" Version="1.0.206" />
                    
Directory.Packages.props
<PackageReference Include="Temelie.Repository" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Temelie.Repository --version 1.0.206
                    
#r "nuget: Temelie.Repository, 1.0.206"
                    
#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.
#:package Temelie.Repository@1.0.206
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Temelie.Repository&version=1.0.206
                    
Install as a Cake Addin
#tool nuget:?package=Temelie.Repository&version=1.0.206
                    
Install as a Cake Tool

Temelie.Repository

A lightweight repository on EF Core for Temelie.Entities. It provides query specifications, lifecycle events, automatic audit fields, and set-based bulk operations.

dotnet add package Temelie.Repository
dotnet add package Temelie.Repository.SourceGenerator

Setup

  1. Context. Create a DbContext from the generated DbContextBase (see Temelie.Repository.SourceGenerator):

    [ExportTransient(typeof(IRepositoryContext))]
    public partial class AppDbContext(IModelBuilderContext context, DbContextOptions<AppDbContext> options)
        : DbContextBase(context, options), IRepositoryContext
    {
        public DbContext DbContext => this;
    }
    
  2. Repository. Create a repository by deriving from DefaultRepository, which implements IDefaultRepository. Tell it how to create a context and who the current user is:

    [ExportTransient(typeof(IDefaultRepository))]
    public class AppRepository(IDbContextFactory<AppDbContext> factory, IRepositoryEventFactory events)
        : DefaultRepository(events)
    {
        protected override IRepositoryContext CreateContext() => factory.CreateDbContext();
        protected override string GetCreatedModifiedBy() => "system";   // e.g. the signed-in user
    }
    

    To restrict a repository to one project's entities, derive from RepositoryBase and constrain to the generated IProjectEntity. See AdventureWorks.Server.Repository for an example.

  3. EF Core provider. Register the provider and the context factory, for example in an IStartupConfiguration:

    services.AddDbContextFactory<AppDbContext>(options => options.UseSqlServer(connectionString));
    

Querying

Queries can be inline predicates, or reusable specifications (IQuerySpec<T>, IQueryAndTransformSpec<T, TResult>):

var person = await repository.GetSingleAsync(new PersonSingleQuery(id));        // generated primary-key query
var active = await repository.GetListAsync<Person>(p => p.IsActive, q => q.OrderBy(p => p.LastName));
var count  = await repository.GetCountAsync<Person>(p => p.IsActive);

public class CustomersByTerritory : IQueryAndTransformSpec<Customer, CustomerByTerritory>
{
    public IQueryable<Customer> Apply(IRepositoryContext context, IQueryable<Customer> query) =>
        query.Where(c => c.TerritoryId.HasValue);

    public IQueryable<CustomerByTerritory> Transform(IRepositoryContext context, IQueryable<Customer> query) =>
        query.GroupBy(c => c.TerritoryId!.Value).Select(g => new CustomerByTerritory { TerritoryId = g.Key, Count = g.Count() });
}

Saving

  • Entities: AddAsync, UpdateAsync, DeleteAsync, and their ...RangeAsync versions.
  • Bulk operations are set-based and run in the database without loading entities:
    • DeleteFromQueryAsync returns the number of deleted rows.
    • UpdateFromQueryAsync also sets the modified audit fields.
    • InsertFromQueryAsync copies rows from one entity type into another. It quotes names with backticks, so it works with MySQL and SQLite but not SQL Server, and its selector can't introduce joins or subqueries.
    • MergeFromQueryAsync inserts, updates, and optionally deletes rows, and returns a MergeResult.

Audit fields and events

  • Audit fields: on add, CreatedDate and CreatedBy are set, and on add and update, ModifiedDate and ModifiedBy are set. This applies to any entity implementing the Temelie.Entities audit interfaces. The user name comes from GetCreatedModifiedBy().

  • Event providers: an IRepositoryEventProvider<T> can filter queries (OnQueryAsync) and react before and after add, update, and delete:

    [ExportProvider(typeof(IRepositoryEventProvider<Person>))]
    public class PersonEvents : IRepositoryEventProvider<Person> { ... }
    

Provider-specific model configuration

IModelBuilderExtensions (UseIdentityColumn, HasTrigger) isolates database-specific model configuration. To customize it for your EF Core provider, export your own implementation with a lower Priority.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Temelie.Repository:

Package Downloads
Temelie.Repository.EntityFrameworkCore

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.207 37 11/7/2026
1.0.206 33 11/7/2026
1.0.205 36 11/7/2026
1.0.204 37 11/7/2026
1.0.202 6,020 10/13/2026
1.0.201 7,452 8/28/2026
1.0.200 202 8/26/2026
1.0.199 69 8/21/2026
1.0.196 62 8/21/2026
1.0.195 60 8/21/2026
1.0.194 2,007 8/19/2026
1.0.193 62 8/12/2026
1.0.192 23,221 7/21/2026
1.0.191 4,154 7/13/2026
1.0.190 1,020 7/9/2026
1.0.189 22,553 2/18/2026
1.0.188 70 2/13/2026
1.0.187 180 11/21/2025
1.0.186 4,636 11/20/2025
1.0.185 117 11/20/2025
Loading failed