Extenso.Data.Entity
10.0.1
dotnet add package Extenso.Data.Entity --version 10.0.1
NuGet\Install-Package Extenso.Data.Entity -Version 10.0.1
<PackageReference Include="Extenso.Data.Entity" Version="10.0.1" />
<PackageVersion Include="Extenso.Data.Entity" Version="10.0.1" />
<PackageReference Include="Extenso.Data.Entity" />
paket add Extenso.Data.Entity --version 10.0.1
#r "nuget: Extenso.Data.Entity, 10.0.1"
#:package Extenso.Data.Entity@10.0.1
#addin nuget:?package=Extenso.Data.Entity&version=10.0.1
#tool nuget:?package=Extenso.Data.Entity&version=10.0.1
<img src="https://github.com/gordon-matt/Extenso/blob/master/_Misc/ExtensoLogo.png" alt="Logo" width="250" />
Extenso.Data.Entity
Intro
This package contains a generic IRepository<TEntity> and IMappedRepository<TModel, TEntity> implementations for Entity Framework,
as well as other data-related extension methods and helper classes.
Getting Started
The first thing you're going to need to do is have an IDbContextFactory implementation. Example:
public class ApplicationDbContextFactory : IDbContextFactory
{
private readonly IConfiguration configuration;
public ApplicationDbContextFactory(IConfiguration configuration)
{
this.configuration = configuration;
}
private DbContextOptions<ApplicationDbContext> options;
private DbContextOptions<ApplicationDbContext> Options
{
get
{
if (options == null)
{
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
optionsBuilder.UseSqlServer(configuration.GetConnectionString("DefaultConnection"));
options = optionsBuilder.Options;
}
return options;
}
}
public DbContext GetContext() => new ApplicationDbContext(Options);
public DbContext GetContext(string connectionString)
{
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
optionsBuilder.UseInMemoryDatabase(connectionString);
return new ApplicationDbContext(optionsBuilder.Options);
}
}
Next, you can register the EntityFrameworkRepository in your dependency injection container. An example:
// Regular direct to entity repository:
services.AddScoped(typeof(IRepository<>), typeof(EntityFrameworkRepository<>));
// Mapped repository, which maps between entities and models:
services.AddScoped(typeof(IMappedRepository<,>), typeof(ExtensoMapperEntityFrameworkRepository<,>));
// Or using the Extenso.Data.Entity.AutoMapper package, you could do this:
services.AddScoped(typeof(IMappedRepository<,>), typeof(AutoMapperEntityFrameworkRepository<,>));
Now just inject the repository into your classes and use it:
public class BlogService
{
private readonly IRepository<BlogCategory> blogCategoryService;
private readonly IRepository<BlogPost> blogPostService;
private readonly IRepository<BlogTag> blogTagService;
public BlogCategoryService(
IRepository<BlogCategory> blogCategoryService,
IRepository<BlogPost> blogPostService,
IRepository<BlogTag> blogTagService)
{
this.blogCategoryService = blogCategoryService;
this.blogPostService = blogPostService;
this.blogTagService = blogTagService;
}
public async Task<IEnumerable<BlogCategory>> GetCategoriesAsync(int tenantId) =>
await blogCategoryService.FindAsync(new SearchOptions<BlogCategory>
{
Query = x =>
x.TenantId == tenantId,
Include = query => query
.Include(x => x.Posts)
.ThenInclude(x => x.Tags),
OrderBy = query => query.OrderBy(x => x.Name),
SplitQuery = true, // Optional, defaults to false
});
// etc...
}
All CRUD operations are supported, including paging, searching, and sorting.
Even projections are supported via method overloads of Find(), FindAsync(), FindOne(), and FindOneAsync().
Limitations
The mapped repositories are currently unable to support filtered includes. Either use the normal IRepository<> which does support that, or cast your IMappedRepository<,> to the relevant implementation and use GetContext() to run your own advanced queries that way. Example:
var efRepository = repository as ExtensoMapperEntityFrameworkRepository<ProductModelViewModel, ProductModel>;
using var context = efRepository.GetContext();
var advancedQuery = context.Set<ProductModel>()
.Include(x => x.Products)
.ThenInclude(x => x.ProductSubcategory)
.Include(x => x.ProductModelIllustrations)
.AsSplitQuery()
.IgnoreAutoIncludes()
.TagWith("My advanced query!")
.Where(x => x.ModifiedDate >= DateTime.UtcNow.AddYears(-10))
.ToList()
.Select(x => x.MapTo<ProductModelViewModel>())
.ToList();
Or simply just use your DbContext without any repository for those situations.
| 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
- Extenso.Data (>= 10.0.1)
- Extenso.Data.Entity.Abstractions (>= 10.0.1)
- Extenso.Mapping (>= 10.0.1)
- LinqKit.Core (>= 1.2.9)
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Extenso.Data.Entity:
| Package | Downloads |
|---|---|
|
Extenso.AspNetCore.OData
Package Description |
|
|
MantleFramework.Data.Abstractions
Package Description |
|
|
Extenso.Data.Entity.AutoMapper
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.1 | 107 | 11/20/2025 |
| 10.0.0 | 275 | 11/13/2025 |
| 9.5.0 | 286 | 11/13/2025 |
| 9.4.0 | 246 | 6/16/2025 |
| 9.3.2 | 274 | 6/9/2025 |
| 9.3.1 | 225 | 6/2/2025 |
| 9.3.0 | 180 | 5/25/2025 |
| 9.2.0 | 156 | 5/3/2025 |
| 9.1.0 | 510 | 3/23/2025 |
| 9.0.0 | 216 | 1/4/2025 |
| 8.0.0 | 207 | 5/15/2024 |
| 7.0.0 | 1,237 | 11/27/2022 |
| 6.1.0 | 567 | 11/18/2022 |
| 6.0.2 | 2,309 | 5/21/2022 |
| 6.0.1 | 1,135 | 2/21/2022 |
| 6.0.0 | 948 | 1/14/2022 |
| 5.0.0 | 951 | 12/6/2020 |
| 3.1.0 | 13,278 | 6/15/2020 |
| 2.0.1 | 919 | 3/22/2020 |
| 2.0.0 | 1,095 | 2/24/2020 |
| 1.2.1 | 793 | 9/10/2019 |
| 1.2.0 | 1,143 | 2/27/2019 |
| 1.1.3 | 1,224 | 10/26/2018 |
| 1.1.2 | 1,788 | 6/30/2018 |
| 1.1.0 | 1,695 | 6/20/2018 |
| 1.0.1 | 1,440 | 5/23/2018 |
| 1.0.0 | 1,843 | 5/17/2018 |