Muslim.GenericRepository.Interface 10.0.1

dotnet add package Muslim.GenericRepository.Interface --version 10.0.1
                    
NuGet\Install-Package Muslim.GenericRepository.Interface -Version 10.0.1
                    
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="Muslim.GenericRepository.Interface" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muslim.GenericRepository.Interface" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Muslim.GenericRepository.Interface" />
                    
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 Muslim.GenericRepository.Interface --version 10.0.1
                    
#r "nuget: Muslim.GenericRepository.Interface, 10.0.1"
                    
#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 Muslim.GenericRepository.Interface@10.0.1
                    
#: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=Muslim.GenericRepository.Interface&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Muslim.GenericRepository.Interface&version=10.0.1
                    
Install as a Cake Tool

Muslim.GenericRepository.Interface

The repository interfaces only: IRepository<TEntity> and the interfaces it is built from — reads, writes, soft delete, bulk operations, counts, raw SQL and save. No EF Core implementation.

dotnet add package Muslim.GenericRepository.Interface

Use this package in projects that should depend on the contract only, such as a Domain or Application project. For a working repository, install Muslim.GenericRepository instead — it brings this package with it.

Quick start

In the Application project, declare the repository and use it:

using Muslim.GenericRepository.Interface;

public interface IProductRepository : IRepository<Product> { }

public class ProductService(IProductRepository products)
{
    public Task<List<Product>> GetCheapAsync()
        => products.FindAsync(x => x.Price < 10, isTracking: false);

    public async Task RenameAsync(int id, string name)
    {
        var product = await products.GetByIdAsync(id);
        product.Name = name;
        await products.SaveUpdateAsync(product);
    }
}

In the Data project, which references Muslim.GenericRepository, supply the class:

using Muslim.GenericRepository.Repositories;

internal class ProductRepository : Repository<Product>, IProductRepository { }

The Application project never sees EF Core.

Namespaces

IRepository<T> and the interfaces it is built from are in different namespaces. Import both:

using Muslim.GenericRepository.Interface;  // IRepository<T>
using Muslim.IGenericRepository;           // ICreate<T>, IFind<T>, IDelete<T>, ...

What IRepository includes

IRepository<TEntity> works with any TEntity that inherits Entity from Muslim.EntityAndDto.

Interface Covers
IGetById<T> find by primary key, as an entity or a DTO
IGetAll<T> read the whole table
IFind<T> read by condition, or by an IFilter<T> for grids with paging, sorting and search
IFirstOrDefault<T> the first match, or null
ISingleOrDefault<T> the only match; throws if there is more than one
ICreate<T> insert, from an entity or a DTO
IUpdate<T> update, keeping the audit columns from the database
IDelete<T> delete, including bulk DeleteWhereAsync
ISoftDelete<T> soft delete and restore, including bulk
IEntityState<T> change-tracker access: detach, set state
ICount<T> / IAny<T> counts and "does any row exist" checks
ISqlOperations<T> raw and interpolated SQL
ISave<T> save staged changes

Query and QueryAsNoTracking give you the IQueryable for anything else.

Rules every implementation follows

  • Create adds the change, SaveCreate adds it and saves. The same goes for update, delete and soft delete. Use the first form when several changes must be saved together.
  • The implementation fills the audit columns: CreatedBy and CreatedDate on insert, UpdateBy and UpdateDate on update, IsDeleted, DeletedBy and DeletedDate on soft delete. All dates are UTC.
  • Reads that return entities take isTracking, true by default. Reads that return a DTO are never tracked.
  • Bulk methods (*WhereAsync, *ByIdsAsync) run one SQL statement and need no Save(). They do not load rows, so the change tracker never sees them.

Every member has XML documentation with an example, so your IDE shows it on hover.

Package Use it for
Muslim.EntityAndDto Base entity and DTO classes
Muslim.Filter Filtering, sorting and paging
Muslim.Inject Automatic dependency registration

License

See LICENSE.txt.

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 (2)

Showing the top 2 NuGet packages that depend on Muslim.GenericRepository.Interface:

Package Downloads
Muslim.GenericRepository

EF Core repository for entities with audit columns: reads, writes, soft delete, bulk operations and raw SQL, with CreatedBy/UpdateBy/DeletedBy and UTC timestamps written automatically. Implements Muslim.GenericRepository.Interface.

Muslim.GenericService

Generic CRUD service over Muslim.GenericRepository.Interface: Service<TEntity> implements IService<TEntity> (Muslim.GenericService.Interface) and wraps every repository read, write, soft delete, bulk operation and count, validate DTOs with Muslim.Validator, and return Muslim.Result Result<T> instead of throwing.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1 123 10/15/2026
8.0.0 206 9/23/2026
2.3.3 183 8/10/2026
2.2.5 259 1/19/2025

Documentation only; no member changed. Corrects XML examples for Find(condition, selector) and the FirstOrDefault/SingleOrDefault<TMap> pairs that failed to compile with CS0121 (type the lambda parameter), and documents the Muslim.GenericRepository 10.0.1 update behavior (stale tracked copies are released; IgnoreUpdateProperty stamps audit columns). See CHANGELOG.md.