I created a repository class that I want to use in the code behind the page. I am using constructor injection in code by page to create an instance of the repository.
Repository Class:
BritanniaPremierEntities PBEntities = new BritanniaPremierEntities(); public IQueryable<TradeRoutes> GetRoutes() { var routes = PBEntities.TradeRoutes.OrderBy(c => c.ConsignmentDate); return routes; } public IQueryable<TradeRoutes> GetExpiredRoutes() { var routes = PBEntities.TradeRoutes.Where( c => c.ConsignmentDate <= System.DateTime.Now); return routes; }
Code by page
private IRepository repos; public Admin_TradeRoutesAdmin() : this(new Repository()) { } public Admin_TradeRoutesAdmin(IRepository repos) { this.repos = repos; } public IQueryable GetTradeRoutes() {
That's where I got a little confused. How to ensure proper storage location? For example, I cannot wrap repository calls with statements in code per page, thereby using the dispose method in the repository.
source share