public Repository(InMemoryDbTable <TKey, TEntity> table) { if (table == null) { throw new ArgumentNullException("table"); } _table = table; }
public InMemoryDbTable <TKey, TEntity> GetTable <TKey, TEntity>() where TEntity : class, IKeyed <TKey> { InMemoryDbTable <TKey, TEntity> table; Type type = typeof(TEntity); Type key = typeof(TKey); string hash = type + key.ToString(); if (_tables.ContainsKey(hash)) { table = (InMemoryDbTable <TKey, TEntity>)_tables[hash]; } else { table = new InMemoryDbTable <TKey, TEntity>(); _tables[hash] = table; } return(table); }
public IKeyedReadOnlyRepository <TKey, TEntity> CreateKeyedReadOnlyRepository <TKey, TEntity>() where TEntity : class, IKeyed <TKey> { InMemoryDbTable <TKey, TEntity> table = _db.GetTable <TKey, TEntity>(); return(new Repository <TKey, TEntity>(table)); }