daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. x.For<IDbContext>().HttpContextScoped().Use(context => new MyContext());
  2.    
  3. public interface IDbContext : IDisposable
  4.     {
  5.         IDbSet<TEntity> Set<TEntity>() where TEntity : class;
  6.         DbEntityEntry<TEntity> Entry<TEntity>(TEntity entity) where TEntity : class;
  7.         int SaveChanges();
  8.     }
  9.    
  10. public class FakeDb : IDbContext
  11. {
  12.     private Dictionary<Type, Object> _lists = new Dictionary<Type, Object>();
  13.     public List<T> GetList<T>()
  14.     {
  15.         var type = typeof(T);
  16.         if(!_lists.Contains(type))
  17.         {
  18.             _lists.Add(type, new List<T>());
  19.         }
  20.         return (List<T>)_lists[type];
  21.     }
  22.  
  23.     ///
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top