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 classwhere T : - {
- 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 { IEnumerableGetAll(); - T GetById(object Id);
- }
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 ?
Jenith ThakkarPosted Jan 16, 2019, 10:34 PM