SimpleEfCoreRepository 1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SimpleEfCoreRepository --version 1.0.2
NuGet\Install-Package SimpleEfCoreRepository -Version 1.0.2
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="SimpleEfCoreRepository" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleEfCoreRepository --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SimpleEfCoreRepository, 1.0.2"
#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.
// Install SimpleEfCoreRepository as a Cake Addin #addin nuget:?package=SimpleEfCoreRepository&version=1.0.2 // Install SimpleEfCoreRepository as a Cake Tool #tool nuget:?package=SimpleEfCoreRepository&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EF.Core.Repository
Simple repository for Ef.Core with basic CRUD functionality The reason I implemented this is because I found myself re-writing basic CRUD functionality over and over again. Most of the time:
- use
.include(...)
to include eager load associated entities - update (add/delete/update) children properties by Id
Basic setup
- Entity should implement
IEntity<TId>
public class DummyModel : IEntity<int>
{
public int Id { get; set; }
public string Name { get; set; }
public List<Nested> Children { get; set; }
}
- Create profile which is used to update an entity given a DTO
public class DummyModelProfile : IEntityProfile<DummyModel, int>
{
private readonly IEntityProfileAuxiliary _auxiliary;
// Optionally inject utility for list add/delete
public DummyModelProfile(IEntityProfileAuxiliary auxiliary)
{
_auxiliary = auxiliary;
}
public DummyModel Update(DummyModel entity, DummyModel dto)
{
entity.Name = dto.Name;
// ModifyList will try to add/delete entities based on Id based on whether they
// appear in dto.Children or not
entity.Children = _auxiliary.ModifyList<Nested, int>(entity.Children, dto.Children);
// Return entity or response
// This will be used as a return value for update method in BasicCrud
return entity;
}
// Intercept IQueryable to include related entities
public IQueryable<DummyModel> Include<TQueryable>(TQueryable queryable) where TQueryable : IQueryable<DummyModel>
{
return queryable.Include(x => x.Children);
}
}
- Register dependency via
IServiceCollection
extension
var serviceProvider = services
.AddEfRepository<EntityDbContext>(options => options
.Profiles(Assembly.GetExecutingAssembly()));
- Use
IBasicCrud
IEfRepository repo = ... // DI inject IEfRepository
// Get IBasicCrud instance
IBasicCrud<DummyModel> = repo.For<DummyModel>();
- Available methods in
IBasicCrud
Task<IEnumerable<TSource>> GetAll();
Task<TSource> Get(id);
Task<TSource> Save(dto);
Task<TSource> Delete(id);
Task<TSource> Update(id, dto);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Microsoft.EntityFrameworkCore (>= 3.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.0.21 | 173 | 12/22/2024 | |
3.0.20 | 158 | 12/10/2024 | |
3.0.19 | 211 | 11/15/2024 | |
3.0.18 | 125 | 11/9/2024 | |
3.0.17 | 92 | 11/9/2024 | |
3.0.16 | 88 | 11/9/2024 | |
3.0.15 | 135 | 11/5/2024 | |
3.0.14 | 427 | 4/28/2023 | |
3.0.13 | 239 | 4/16/2023 | |
3.0.12 | 216 | 4/16/2023 | |
3.0.11 | 257 | 3/21/2023 | |
3.0.10 | 262 | 3/9/2023 | |
3.0.9 | 250 | 3/9/2023 | |
3.0.8 | 446 | 10/13/2022 | |
3.0.7 | 491 | 9/18/2022 | |
3.0.6 | 465 | 9/10/2022 | |
3.0.5 | 438 | 9/10/2022 | |
3.0.4 | 433 | 9/10/2022 | |
3.0.3 | 450 | 9/8/2022 | |
3.0.2 | 455 | 9/8/2022 | |
3.0.1 | 709 | 7/12/2022 | |
3.0.0 | 540 | 6/20/2022 | |
2.1.5 | 502 | 6/20/2022 | |
2.1.4 | 472 | 4/19/2021 | |
2.1.3 | 413 | 4/19/2021 | |
2.1.2 | 379 | 4/18/2021 | |
2.1.1 | 451 | 4/17/2021 | |
2.1.0 | 434 | 4/17/2021 | |
2.0.2 | 461 | 1/2/2021 | |
2.0.1 | 490 | 1/2/2021 | |
2.0.0 | 431 | 12/28/2020 | |
1.0.8 | 508 | 11/5/2020 | |
1.0.7 | 511 | 8/16/2020 | |
1.0.6 | 492 | 8/10/2020 | |
1.0.5 | 474 | 8/10/2020 | |
1.0.4 | 547 | 6/20/2020 | |
1.0.3 | 521 | 6/20/2020 | |
1.0.2 | 479 | 6/17/2020 | |
1.0.1 | 554 | 5/25/2020 | |
1.0.0 | 581 | 5/24/2020 |
Minor improvement to the auxiliary class