Problem
How to implement repository pattern in asp.net core 2.1 visual studio 2017 with SQL server 2012 ?
i work on project work on repository pattern but i cannot implement it
model Employee
- public class Employee
- {
- public int EmployeeId { get; set; }
- public int BranchCode { get; set; }
- public string EmployeeName { get; set; }
- public int EmployeeAge { get; set; }
- }
- Repository public class RepositoryTab : IrepositoryTab where T : class
- {
- protected TabDbContext db { get; set; }
- private DbSet dbSet;
- public RepositoryTab(TabDbContext Tabdb)
- {
- db = Tabdb;
- dbSet = db.Set();
- }
- public IEnumerable GetAll()
- {
- return dbSet.ToList();
- }
- }
- public interface IrepositoryTab where T : class { IEnumerable GetAll();
- T GetById(object Id);
- }
1- How to define repository on controller Employee to call function GetAll on constructor?
meaning how to define repository on constructor of controller
3- suppose i have compost key how to use getbyid suppose i have (Employeid,branchcode) as compost key ?
are compost key define as fluent api or annotation or what ?
please can you help me and give me details if possible
can any one answer me of this question please ?