Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Orbis25/FoundationKit/llms.txt
Use this file to discover all available pages before exploring further.
IMapRepository is FoundationKit’s AutoMapper-aware repository interface. Where IBaseRepository<TModel> works directly with entity types, IMapRepository accepts strongly-typed input DTOs (TInputModel), edit DTOs (TEditModel), and projects query results directly to output DTOs (TDtoModel) — keeping your controllers and service layer completely free of entity types. Every operation accepts or returns the appropriate DTO, and AutoMapper handles all translation between the wire layer and the database layer transparently.
This design means your API endpoints never need to reference EF Core entity classes. Input validation, serialization, and persistence concerns are each confined to their own models, and the repository interface enforces those boundaries at compile time through its generic constraints.
Interface Variants
FoundationKit ships two related interfaces inFoundationKit.Repository.Interfaces:
| Interface | Type Parameters | Purpose |
|---|---|---|
IMapRepository<TInputModel, TEditModel, TDtoModel> | 3 | Standard CRUD operations over DTOs |
IMapRepository<T, TInputModel, TEditModel, TDtoModel> | 4 | Extends the 3-param variant — adds GetEntities and UpdatePartialEntityAsync for direct entity access |
TEntity (T) for scenarios where you need to drop down to raw entity manipulation (e.g., partial updates or complex bulk queries).
Generic Constraints
TInputModel : BaseInput— The DTO used for create operations.BaseInputis an empty marker class; derive from it and add your create-specific properties.TEditModel : BaseEdit— The DTO used for update operations.BaseEditcarries[JsonIgnore]audit fields (Id,CreatedAt,CreatedBy, etc.) so the client cannot overwrite them.TDtoModel : BaseOutput— The read-side DTO returned by all query methods.BaseOutputexposesId,CreatedAt,CreatedAtStr, andCreatedBy.T : BaseModel— The EF Core entity (4-parameter variant only). Used byGetEntitiesandUpdatePartialEntityAsync.
Methods
GetPaginatedList
Returns a single page of projectedTDtoModel results. Filtering and ordering expressions are written against TDtoModel properties, not the raw entity.
Pagination parameters:
Page (1-based), Qyt (items per page), OrderByDesc (sort direction), NoPaginate (return all results without paging), and Query (free-text token for optional use in your expression).Optional filter predicate applied against the projected DTO query before Skip/Take.
Optional DTO property selector for ordering. Defaults to
CreatedAt when null.Propagates cancellation from the calling HTTP request or background job.
Navigation-property selectors for eager loading.
Contains
ActualPage, Qyt, PageTotal, Total, and Results (IReadOnlyCollection<TDtoModel>).GetList
Returns a fully materialised list ofTDtoModel instances matching the optional predicate, without pagination.
Optional filter predicate. Pass
null to retrieve all rows.true for descending order; false for ascending.Property selector for ordering. Falls back to
CreatedAt when null.Propagates cancellation.
Navigation properties for eager loading.
An in-memory collection of projected DTOs. For a composable query, use
GetAll instead.GetAll
Returns a composableIQueryable<TDtoModel> that projects entity data via AutoMapper’s ProjectTo. No data is fetched until the query is enumerated.
Optional
Where filter on the projected DTO query.Sort direction.
Optional sort-property selector.
Navigation properties for eager loading.
A deferred, AutoMapper-projected query. Chain further LINQ operators or call
.ToListAsync() to execute.Create
Maps aTInputModel to the underlying entity, persists it in a transaction, and returns the saved record as a TDtoModel.
The input DTO carrying the data for the new entity. Must derive from
BaseInput. AutoMapper translates it to the entity before insertion.Propagates cancellation.
The persisted record projected back to
TDtoModel, including any database-assigned values such as Id and CreatedAt.Update
Maps aTEditModel to the underlying entity and persists the update. Two overloads are available: one that exposes the verifyEntity flag, and a convenience overload that omits it (equivalent to calling the full overload with verifyEntity: false). When verifyEntity is true, the repository fetches the current DTO first to preserve CreatedBy and CreatedAt audit fields.
The edit DTO with updated field values. Must derive from
BaseEdit. The Id property on BaseEdit identifies which record to update.Propagates cancellation.
When
true, performs a GetById before updating to copy immutable audit fields (CreatedBy, CreatedAt) from the existing record onto the edit model. Set to false to skip the pre-fetch if you have pre-populated those fields yourself. The two-parameter convenience overload always behaves as if verifyEntity is false.The updated record as
TDtoModel, or null if verifyEntity is true and no matching row was found.GetById
Fetches a single entity by primary key (Guid) and projects it to TDtoModel.
The primary key of the record to fetch.
When
true, the query is executed with AsNoTracking(). Useful for read-only operations to reduce EF Core overhead.Propagates cancellation.
Navigation properties to include on the projected DTO query.
The projected DTO, or
null if no record with the given Id exists.SoftRemove
Performs a logical delete by fetching the DTO, mapping it back to the entity, settingIsDeleted = true, and persisting the update.
Primary key of the entity to soft-delete.
Propagates cancellation.
true if the record was found and soft-deleted; false if no entity with the given Id was found.Remove
Permanently deletes the entity from the database. The record is fetched as a DTO, mapped back to the entity, then removed.Primary key of the entity to delete.
Propagates cancellation.
true if the record was found and removed; false otherwise.Exist
Checks whether any projectedTDtoModel matches the given predicate.
Filter predicate. When
null, the method returns false (unlike IBaseRepository.ExistAsync which returns true for any row when the expression is null).Propagates cancellation.
true when at least one projected DTO matches the expression; false otherwise, including when no expression is provided.GetOneAsync
Returns the first projectedTDtoModel matching the predicate, or null when nothing matches.
Filter predicate applied to the projected DTO query.
Propagates cancellation.
The first matching DTO, or
null.Count
Counts the number of projected DTOs that satisfy all supplied predicates.Propagates cancellation.
Zero or more filter predicates that are ANDed together. Passing none counts all rows.
Row count satisfying all predicates.
CommitAndResultAsync
Flushes all pending EF Core change-tracker mutations within a database transaction and returnsnull on success, or an error message string on failure. The transaction is automatically rolled back if an exception is caught.
Propagates cancellation.
null on a successful commit; the base exception message string if the transaction failed.GetEntities (extended interface only)
Returns a rawIQueryable<T> over the underlying entity set. Available only on IMapRepository<T, TInputModel, TEditModel, TDtoModel>.
Optional filter applied directly to the entity
DbSet. Pass null to get an unfiltered entity queryable.A deferred, untracked entity query. Useful when you need entity-level access not available through the DTO projection.
UpdatePartialEntityAsync (extended interface only)
Attaches an entity and marks only the listed properties asModified, producing a targeted UPDATE statement. Available only on IMapRepository<T, TInputModel, TEditModel, TDtoModel>.
The entity to partially update. Must have its
Id property set.Property selectors for each column to include in the
UPDATE. Unlisted properties are untouched.Propagates cancellation.
Completes when
SaveChangesAsync has finished.Usage Example
ImplementIMapRepository by extending MapRepository<TContext, TEntity, TInputModel, TEditModel, TDtoModel>.