Can someone (hopefully Rob) explain how to implement the new SubSonicRepository<> Pattern? I have used it with the old version and the MVC templates (in web forms) using the following initialization.
public IRepository<StaffingPosition> _StaffingPositionsRepository;
public StaffingBase()
{
_StaffingPositionsRepository = new SubSonicRepository<StaffingPosition>();
}
public StaffingBase(IRepository<StaffingPosition> staffingpositionsRepo)
{
_StaffingPositionsRepository = staffingpositionsRepo;
}
Note that my WCF Service inherits this class for ease of access.
Now SubSonicRepository() requires an argument of IQuerySurface and I'm not sure the best way to make this happen. I really dig the IRepository pattern and want to try to stick with it if possible…That is, unless anyone has better ideas. Thanks!
Best Answer
The templates generate a new class that implement IQuerySurface, the name of which you can configure in the main .tt file (usually something like NorthwindDb). Usually all that is needed is to pass a new instance of this class to the repository: