EFRepo.EntityFramework.Core
1.3.3
See the version list below for details.
dotnet add package EFRepo.EntityFramework.Core --version 1.3.3
NuGet\Install-Package EFRepo.EntityFramework.Core -Version 1.3.3
<PackageReference Include="EFRepo.EntityFramework.Core" Version="1.3.3" />
paket add EFRepo.EntityFramework.Core --version 1.3.3
#r "nuget: EFRepo.EntityFramework.Core, 1.3.3"
// Install EFRepo.EntityFramework.Core as a Cake Addin #addin nuget:?package=EFRepo.EntityFramework.Core&version=1.3.3 // Install EFRepo.EntityFramework.Core as a Cake Tool #tool nuget:?package=EFRepo.EntityFramework.Core&version=1.3.3
EFRepo.EntityFrameworkCore
EFRepo generic repository implemented with .Net core 6
Installation
Install-Package EFRepo.EntityFramework.Core -Version 1.3.3
Update description
in this version of events, package updated some feature such as:
- Update package to .net 6
- Update Redis cache for repository
Usage
The library using repository Pattern source code organization. So, to using you need create Interface Base include repositories and implement that interface.
How to use?
You need make sure Interface and Implement class to included repository pattern
Step 1: make interface class in your project
interface IAbc : IRepository<Abc>
Step 2: make implement class in your project
public class IplAbc: Repository<Abc>, IAbc
public IConfiguration _Configuration { get; }
//Your data context
public yourContext _context;
public IplAbc(yourContext context, IConfiguration configuration) : base(context)
{
_Configuration = configuration;
_context = context;
}
//override this function to use transaction control
public override void SaveChange()
{
base.SaveChange();
}
Step 3: make base class to declare the repositories in your project
public interface IBase
IAbc abcRepository { get; }
public class BaseImplement : IBase
private YourDbContext _dbContext;
private IAbc _abcRepository;
public IConfiguration _Configuration { get; }
public IplBase(YourDbContext dbContext, IConfiguration configuration)
{
_dbContext = dbContext;
_Configuration = configuration;
}
public IAbc abcRepository
{
get
{
return _abcRepository ?? (_abcRepository = new IplAbc(_dbContext, _Configuration));
}
}
//Other repositories
Step 4: Usage
IBase _ibase;
public AbcController(IBase @base){
_ibase = @base;
}
public IActionResult Index(int id)
{
Expression<Func<abc, bool>> mypredicate = (o => o.Id == id);
var data = _ibase.contentsRepository.Read(mypredicate);
return View(data);
}
Integration Execute Query Multiple Async using only Procedure of SQL server.
async Task<dynamic> ExecuteQueryMultipleAsync(string spName, object param = null, IEnumerable<MapItem> mapItems = null)
Usage
var unitOfWork = new UnitOfWorkFactory(_cnnString);
using (var u = unitOfWork.Create(false))
{
var mapItems = new List<MapItem>()
{
new MapItem(typeof(CustomerEntity), DataRetriveTypeEnum.FirstOrDefault, "CustomerEntity"),
new MapItem(typeof(ContractEntity), DataRetriveTypeEnum.List, "ContractEntity"),
};
var p = new DynamicParameters();
p.Add("@CutomerId", CutomerId, DbType.Int32);
var response = await u.ExecuteQueryMultipleAsync(TSQL.GET_CUSTOMER_VIEW, p, mapItems);
var property = (IDictionary<String, Object>)response;
entity.CustomerEntity = (CustomerEntity)property["CustomerEntity"];
entity.ContractEntity = ((List<dynamic>)property["ContractEntity"]).OfType<ContractEntity>().ToList();
}
How to integrated cache services
//Your data context
public yourContext _context;
private EnCache enCache = EnCache.MemoryCache;
private Func<EnCache, ICacheService> _cacheService;
public IplAbc(yourContext context, IConfiguration configuration, Func<EnCache, ICacheService> cacheService) : base(context)
{
_Configuration = configuration;
_context = context;
_cacheService = cacheService;
}
public Abc GetDataUsingCache(Expression<Func<Abc,bool>> expression, string keyCache="")
{
Abc data = new Abc();
if (!string.IsNullOrEmpty(keyCache))
{
data = _cacheService(enCache).Get<Abc>(keyCache);
if (data != null)
return data;
else
{
data = new AbcRepository(_context, _Configuration, _cacheService).Read(expression);
_cacheService(enCache).Set(keyCache, data);
}
}
else
{
data = new AbcRepository(_context, _Configuration, _cacheService).Read(expression);
}
return data;
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Dapper (>= 2.0.123)
- EFCore.BulkExtensions (>= 6.5.1)
- Microsoft.EntityFrameworkCore (>= 6.0.6)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 6.0.6)
- MySql.Data (>= 8.0.29)
- Newtonsoft.Json (>= 13.0.1)
- Oracle.ManagedDataAccess.Core (>= 3.21.61)
- System.Data.SqlClient (>= 4.8.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.