Temelie.Repository
1.0.206
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
<PackageReference Include="Temelie.Repository" Version="1.0.206" />
<PackageVersion Include="Temelie.Repository" Version="1.0.206" />
<PackageReference Include="Temelie.Repository" />
paket add Temelie.Repository --version 1.0.206
#r "nuget: Temelie.Repository, 1.0.206"
#:package Temelie.Repository@1.0.206
#addin nuget:?package=Temelie.Repository&version=1.0.206
#tool nuget:?package=Temelie.Repository&version=1.0.206
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
Context. Create a
DbContextfrom the generatedDbContextBase(see Temelie.Repository.SourceGenerator):[ExportTransient(typeof(IRepositoryContext))] public partial class AppDbContext(IModelBuilderContext context, DbContextOptions<AppDbContext> options) : DbContextBase(context, options), IRepositoryContext { public DbContext DbContext => this; }Repository. Create a repository by deriving from
DefaultRepository, which implementsIDefaultRepository. 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
RepositoryBaseand constrain to the generatedIProjectEntity. SeeAdventureWorks.Server.Repositoryfor an example.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...RangeAsyncversions. - Bulk operations are set-based and run in the database without loading entities:
DeleteFromQueryAsyncreturns the number of deleted rows.UpdateFromQueryAsyncalso sets the modified audit fields.InsertFromQueryAsynccopies 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.MergeFromQueryAsyncinserts, updates, and optionally deletes rows, and returns aMergeResult.
Audit fields and events
Audit fields: on add,
CreatedDateandCreatedByare set, and on add and update,ModifiedDateandModifiedByare set. This applies to any entity implementing theTemelie.Entitiesaudit interfaces. The user name comes fromGetCreatedModifiedBy().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 | Versions 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.14)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.14)
- Temelie.DependencyInjection (>= 1.0.206)
- Temelie.Entities (>= 1.0.206)
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 |