EFCoreExtension 1.8.0
dotnet add package EFCoreExtension --version 1.8.0
NuGet\Install-Package EFCoreExtension -Version 1.8.0
<PackageReference Include="EFCoreExtension" Version="1.8.0" />
<PackageVersion Include="EFCoreExtension" Version="1.8.0" />
<PackageReference Include="EFCoreExtension" />
paket add EFCoreExtension --version 1.8.0
#r "nuget: EFCoreExtension, 1.8.0"
#:package EFCoreExtension@1.8.0
#addin nuget:?package=EFCoreExtension&version=1.8.0
#tool nuget:?package=EFCoreExtension&version=1.8.0
This package is used for generic repository and mapping entity with models
// Install package in project
// Handle dependency injection. Write this code in startup class or in program class (.NET 6)
services.AddScoped(typeof(IRepository<>), typeof(Repository<>)); services.AddScoped(typeof(IGetService<>), typeof(GetService<>)); services.AddScoped(typeof(ICrudService<>), typeof(CrudService<>)); //Create generic repository for entity
EntityName (entity class name - Account)
public class EntityNameRepositoryService : CrudService<EntityName>, IEntityNameRepositoryService { public EntityNameRepositoryService(IRepository<EntityName> repository) : base(repository) { } }
public interface IEntityNameRepositoryService : ICrudService<EntityName> { } // Use repository services
................................
private readonly IEntityNameRepositoryService _entityNameRepositoryService;
public HomeController(IEntityNameRepositoryService entityNameRepositoryService) { this._entityNameRepositoryService = entityNameRepositoryService; }
{
var item = _entityNameRepositoryService.Get(x ⇒ x.ID == Id); var items = _entityNameRepositoryService.GetAll(x ⇒ x.Name == "name");
.Add(entityItem)
.Update(entityItem);
.Delete(x => x.ID == Id)
}
For execute stored procedure follow these steps :- Make a model with fields as stored procedure result
public class SP_Name_Result { public long ID { get; set; } public string Name { get; set; } public long Col1 { get; set; } public int Col2 { get; set; } public DateTime DateCol { get; set; } }
Then make class for execute functions
using EFCoreExtension.Extensions;
using EFCoreExtension.Utility;
using Microsoft.EntityFrameworkCore;
public static class ExecuteSPExtensions {
public static async Task<IList<SP_Name_Result>> SP_Name(this DbContext _context, long? Param1, int? Param2, string Param3)
{
var param1Parameter = Param1.HasValue ?
new ObjectParameter("Param1", Param1) :
new ObjectParameter("Param1", typeof(long));
var param2Parameter = Param2.HasValue ?
new ObjectParameter("Param2", Param2) :
new ObjectParameter("Param2", typeof(int));
var param3Parameter = Param3 != null ?
new ObjectParameter("Param3", Param3) :
new ObjectParameter("Param3", typeof(string));
return await _context.ExecuteFunctionAsync<SP_Name_Result>("SP_Name", param1Parameter, param2Parameter , param3Parameter );
}
}
Call function ----
var _result = (await _context.SP_Name( param1, param2, param3));
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net10.0 was computed. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 8.0.3)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.3)
- Newtonsoft.Json (>= 13.0.3)
- System.Data.SqlClient (>= 4.8.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.