Advertisement
Guest User

Service using disposable repository

a guest
Apr 14th, 2014
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. namespace MyNamespace
  2. {
  3.     public class MyDbService : IMyDbService
  4.     {
  5.         IDbRepository<DbItem> _repository;
  6.     readonly Type _repositoryType;
  7.  
  8.         public MyDbService()
  9.         {
  10.             _repositoryType = typeof(new DbRepository<DbItem>());
  11.         }
  12.  
  13.         public MyDbService(IDbRepository<DbItem> repository)
  14.         {
  15.             _repository = typeof(repository);
  16.         }
  17.  
  18.         public DbItem SomeFunction()
  19.         {
  20.         using (_repository = instantiateRepo())
  21.         {
  22.         // some actions on _repository returning DbItem
  23.         }
  24.         }
  25.  
  26.     IDbRepository instantiateRepo()
  27.     {
  28.         // returns IDbRepository concrete instance using _repositoryType
  29.     }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement