EFRepo.EntityFramework.Core 1.3.8

Suggested Alternatives

EFRepo.EntityFramework.Core 1.4.0

Additional Details

Critical bugs related to Encrypt function.

There is a newer version of this package available.
See the version list below for details.
dotnet add package EFRepo.EntityFramework.Core --version 1.3.8
                    
NuGet\Install-Package EFRepo.EntityFramework.Core -Version 1.3.8
                    
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="EFRepo.EntityFramework.Core" Version="1.3.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EFRepo.EntityFramework.Core" Version="1.3.8" />
                    
Directory.Packages.props
<PackageReference Include="EFRepo.EntityFramework.Core" />
                    
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 EFRepo.EntityFramework.Core --version 1.3.8
                    
#r "nuget: EFRepo.EntityFramework.Core, 1.3.8"
                    
#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 EFRepo.EntityFramework.Core@1.3.8
                    
#: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=EFRepo.EntityFramework.Core&version=1.3.8
                    
Install as a Cake Addin
#tool nuget:?package=EFRepo.EntityFramework.Core&version=1.3.8
                    
Install as a Cake Tool

EFRepo.EntityFrameworkCore

EFRepo generic repository implemented with .Net core 8. The library uses the repository pattern source code organization. So to use it you need to create an interface base that includes the repository and implement that interface. The library makes it easy to use both Linq or ADO with SQL queries or stored procedures.

Installation

Install-Package EFRepo.EntityFramework.Core -Version 1.3.5

Update description

in this version of events, package updated some feature such as:

  • Update package to .net 8
  • Integrate Redis services
  • Update Redis cache for repository
  • Optimize Repository
  • Optimize UnitOfWork for Query T-SQL (store proceduce, query raw,...)

Usage

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 unitofwork 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 redis services

//Your data context
public yourContext _context;
private EnCache enCache = EnCache.MemoryCache;
private Func<EnCache, ICacheService> _cacheService;
public IplAbc(yourContext context, IConfiguration configuration, IDatabase rd) : base(context)
{
        _context = context;
        _configuration = configuration;
        _cnnString = _configuration.GetConnectionString("DefaultConnection");

        if (rdb != null)
        {
            _redisDb = rdb;
            cacheService = new CacheServices(_redisDb);
        }
}
public Abc GetDataUsingCache(Expression<Func<Abc,bool>> expression, string keyCache="")
    {
        Abc data = new Abc();
        if (!string.IsNullOrEmpty(keyCache) && _redisDb != null)
        {                
            data = cacheService.Get<Abc>(keyCache);
            if (data != null)
                return data;
            else
            {
                data = new AbcRepository(_context, _Configuration, _cacheService).Read(expression);
                cacheService.Set<Abc>(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

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.4.0 178 12/9/2024
1.3.9 126 12/5/2024 1.3.9 is deprecated because it has critical bugs.
1.3.8 113 12/7/2024 1.3.8 is deprecated because it has critical bugs.
1.3.7 135 10/17/2024
1.3.6 174 7/14/2024
1.3.5 145 7/12/2024
1.3.4 156 7/4/2024
1.3.3 173 6/30/2024
1.3.2 572 9/20/2022
1.3.1 554 9/20/2022 1.3.1 is deprecated because it has critical bugs.
1.3.0 543 6/27/2022
1.2.2 543 6/2/2022
1.2.1 470 7/28/2022
1.1.2 477 12/20/2021
1.1.0 434 12/6/2021
1.0.0 2,824 11/25/2021