EFRepo.EntityFramework.Core 1.3.3

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.3                
NuGet\Install-Package EFRepo.EntityFramework.Core -Version 1.3.3                
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.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EFRepo.EntityFramework.Core --version 1.3.3                
#r "nuget: EFRepo.EntityFramework.Core, 1.3.3"                
#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 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

MIT

Product 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. 
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.3.7 27 10/17/2024
1.3.6 103 7/14/2024
1.3.5 88 7/12/2024
1.3.4 101 7/4/2024
1.3.3 112 6/30/2024
1.3.2 487 9/20/2022
1.3.1 433 9/20/2022 1.3.1 is deprecated because it has critical bugs.
1.3.0 464 6/27/2022
1.2.2 461 6/2/2022
1.2.1 392 7/28/2022
1.1.2 387 12/20/2021
1.1.0 341 12/6/2021
1.0.0 2,735 11/25/2021