![]() |
VOOZH | about |
dotnet add package Cyrena.Persistence.Core --version 0.5.0
NuGet\Install-Package Cyrena.Persistence.Core -Version 0.5.0
<PackageReference Include="Cyrena.Persistence.Core" Version="0.5.0" />
<PackageVersion Include="Cyrena.Persistence.Core" Version="0.5.0" />Directory.Packages.props
<PackageReference Include="Cyrena.Persistence.Core" />Project file
paket add Cyrena.Persistence.Core --version 0.5.0
#r "nuget: Cyrena.Persistence.Core, 0.5.0"
#:package Cyrena.Persistence.Core@0.5.0
#addin nuget:?package=Cyrena.Persistence.Core&version=0.5.0Install as a Cake Addin
#tool nuget:?package=Cyrena.Persistence.Core&version=0.5.0Install as a Cake Tool
Cyrena.Persistence.Core provides the persistence abstraction layer for the Cyréna framework. It defines the generic repository contract IStore<T>, the persistence builder interface ICyrenaPersistenceBuilder, and extension methods for convenient querying. Concrete implementations (e.g., Cyrena.Persistence.File) provide the actual storage backend.
Target Framework: .NET 10.0
Namespaces: Cyrena.Persistence.Contracts, Cyrena.Persistence.Options, Cyrena.Extensions
IStore<T>Generic repository interface for entity persistence. Supports CRUD operations, querying with specifications, ordering, and paging.
public interface IStore<T> : IDisposable
where T : class, IEntity
{
IQueryable<T> QueryableData { get; }
Task SaveAsync(T entity, CancellationToken cancellationToken = default);
Task AddAsync(T entity, CancellationToken cancellationToken = default);
Task AddManyAsync(IEnumerable<T> entities, CancellationToken cancellationToken = default);
Task UpdateAsync(T entity, CancellationToken cancellationToken = default);
Task DeleteAsync(T entity, CancellationToken cancellationToken = default);
Task<int> DeleteManyAsync(ISpecification<T> specification, CancellationToken cancellationToken = default);
Task<IEnumerable<T>> FindManyAsync(ISpecification<T> specification, IOrderBy<T>? orderBy = default, IPaging? paging = default, CancellationToken cancellationToken = default);
Task<int> CountAsync(ISpecification<T> specification, CancellationToken cancellationToken = default);
Task<T?> FindAsync(ISpecification<T> specification, CancellationToken cancellationToken = default);
}
Key behaviors:
SaveAsync: Upsert operation. Auto-generates Id if null.AddAsync: Insert operation. Auto-generates Id if null.QueryableData: Direct LINQ queryable access to the underlying collection.ICyrenaPersistenceBuilderHelper interface for registering entity stores during DI configuration.
public interface ICyrenaPersistenceBuilder
{
void AddScopedStore<TEntity>(string collectionName) where TEntity : class, IEntity;
void AddSingletonStore<TEntity>(string collectionName) where TEntity : class, IEntity;
}
AddScopedStore: Registers IStore<TEntity> as a scoped service (one per chat/kernel).AddSingletonStore: Registers IStore<TEntity> as a singleton service (application-wide).collectionName: Logical collection/table name for the entity type.CyrenaBuilderExtensions (in Cyrena.Extensions)public static class CyrenaBuilderExtensions
{
public static CyrenaBuilder AddScopedStore<TEntity>(this CyrenaBuilder builder, string collectionName)
where TEntity : class, IEntity;
public static CyrenaBuilder AddSingletonStore<TEntity>(this CyrenaBuilder builder, string collectionName)
where TEntity : class, IEntity;
}
These methods delegate to the ICyrenaPersistenceBuilder registered in CyrenaBuilder.FeatureOptions. The persistence implementation package (e.g., Cyrena.Persistence.File) must be added first.
StoreExtensions (in Cyrena.Extensions)Convenience overloads using Expression<Func<T, bool>> predicates instead of ISpecification<T>.
public static class StoreExtensions
{
public static Task<T?> FindAsync<T>(this IStore<T> store, Expression<Func<T, bool>> predicate, CancellationToken ct = default)
where T : class, IEntity;
public static Task<IEnumerable<T>> FindManyAsync<T>(this IStore<T> store, Expression<Func<T, bool>> predicate,
OrderBy<T>? orderBy = null, Paging? paging = null, CancellationToken ct = default)
where T : class, IEntity;
public static Task<int> CountAsync<T>(this IStore<T> store, Expression<Func<T, bool>> predicate, CancellationToken ct = default)
where T : class, IEntity;
public static Task<int> DeleteManyAsync<T>(this IStore<T> store, Expression<Func<T, bool>> predicate, CancellationToken ct = default)
where T : class, IEntity;
}
These extensions wrap the predicate in an internal AnySpecification<T> that implements ISpecification<T>.
The following types are referenced by IStore<T> and StoreExtensions but defined in concrete persistence implementation packages:
ISpecification<T> - Query specification interfaceSpecification<T> - Base specification implementationIOrderBy<T> - Ordering specification interfaceOrderBy<T> - Ordering implementationIPaging - Paging specification interfacePaging - Paging implementationWhen using Cyrena.Persistence.Core, you must also reference a concrete implementation package that provides these types.
Reference Cyrena.Persistence.Core to:
IEntityIStore<TEntity> for data access in servicesCyrenaBuilder.AddScopedStore<TEntity>() or AddSingletonStore<TEntity>()StoreExtensionsExample:
// Define entity
public class MyData : Entity { public string Value { get; set; } }
// Register store in extension
builder.AddScopedStore<MyData>("my-data");
// Use in service
public class MyService(IStore<MyData> store) { ... }
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.0 | 101 | 5/13/2026 |