Skip to content

IGenericServicesDbContext

Jon Smith edited this page Jan 20, 2015 · 2 revisions

All the GenericServices methods, like ListService, have a common constructor pattern, see below (xxx is the name of the service):

public xxxService(IGenericServicesDbContext db)

The IGenericServicesDbContext interface conforms to the basic Entity Framework DbContext, so for GenericServices use your DbContext you need to add the IGenericServicesDbContext interface to it, i.e.

public class SampleWebAppDb : DbContext, IGenericServicesDbContext
{
   //... etc.

You can see an example of this in the definition of DbContext in SampleMvcWebApp. Do read the Dependency Injection section how this interface makes wiring up GenericServices easy to do.