concept data access layer in category dependency injection
appears as: data access layer, data access layer, The data access layer, data access layers

This is an excerpt from Manning's book Dependency Injection.
Figure 2.4 Compared to figure 2.3, Mary has now implemented the data access layer and the domain layer. The UI layer still remains to be implemented.
![]()
The next listing shows how Mary implements an
Index
method on herHomeController
class to extract the featured products from the database and pass them to the view. To make this code compile, she must add references to both the data access layer and the domain layer. This is because theProductService
class is defined in the domain layer, but theProduct
class is defined in the data access layer.Listing 2.4
Index
method on the default controller classpublic ViewResult Index() { bool isPreferredCustomer = #1 this.User.IsInRole("PreferredCustomer"); #1 var service = new ProductService(); #2 var products = service.GetFeaturedProducts( #3 isPreferredCustomer); #3 this.ViewData["Products"] = products; #4 return this.View(); } #1 Determines whether a customer is a preferred customer #2 Creates ProductService from the domain layer #3 Gets the list of featured products (defined in the data access layer) from the ProductService #4 Stores the list of products in the controller’s generic ViewData dictionary for later use by the view