Skip to content

Russ256/DataRepositoryCore

Repository files navigation

DataRepositoryCore

Generic Data Repositories for Entity Framework Code

Summary

There are two fully generic repositories implemented:

  1. IReadDataRepository - For non tracked entities, use this for faster performance when updates not required.
  2. IDataRepository - For tracked entities.

Instructions

  1. Implement IEntity on your entities.
  2. Implement IDataContext on your DbContext or derive your context from DataContext.
  3. Add the default repositories to the services container using the extension mehthod AddDataRepositories.
  4. Make sure you use the IDataContext interface when adding your EF context:
    services.AddEntityFrameworkSqlServer()
        .AddDbContext<IDataContext, YourDataContext>(options => .....);
  1. Inject into you code:
     public YouClassConstructor(IDataRepository<Customer, Guid> repository)

About

Generic Data Repositories for Entity Framework Code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages