Created
December 29, 2015 10:07
-
-
Save mizrael/9e0669598fad62cc998b to your computer and use it in GitHub Desktop.
simple Mongodb repository factory implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RepositoryFactory : IRepositoryFactory | |
{ | |
private readonly IMongoDatabaseFactory _dbFactory; | |
public RepositoryFactory(IMongoDatabaseFactory dbFactory) | |
{ | |
if (dbFactory == null) | |
throw new ArgumentNullException("dbFactory"); | |
_dbFactory = dbFactory; | |
} | |
public IRepository<TEntity> Create<TEntity>(RepositoryOptions options) | |
{ | |
if (options == null) throw new ArgumentNullException("options"); | |
var db = _dbFactory.Connect(options.ConnectionString, options.DbName); | |
return new Repository<TEntity>(db.GetCollection<TEntity>(options.CollectionName)); | |
} | |
} |
Author
mizrael
commented
Sep 2, 2019
via email
this is a very old piece of code, not sure if I still have it... also these
days I moved towards a more DDD approach for repositories and entities. I
might blog about it one day or another.
Il giorno lun 2 set 2019 alle ore 18:06 Andrew <notifications@github.com>
ha scritto:
… Going through your blog and files, where is new Repository<TEntity> from
on line 17?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/9e0669598fad62cc998b?email_source=notifications&email_token=AAK52KAC4ZZYJ4AQGALPDBLQHU2YTA5CNFSM4IS62LDKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFX76U#gistcomment-3014634>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAK52KH34QWCERG2SXDKZGDQHU2YTANCNFSM4IS62LDA>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment