Last active
September 2, 2019 20:10
-
-
Save mizrael/bec897d4f397ddc7b750 to your computer and use it in GitHub Desktop.
simple mongodb database context 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 DbContext : IDbContext | |
{ | |
public DbContext(IRepositoryFactory repoFactory, string connectionString, string dbName) | |
{ | |
if (string.IsNullOrWhiteSpace(connectionString)) | |
throw new ArgumentNullException("connectionString"); | |
if (string.IsNullOrWhiteSpace(dbName)) | |
throw new ArgumentNullException("dbName"); | |
this.Posts = repoFactory.Create<Entities.Video>(new RepositoryOptions(connectionString, dbName, "posts")); | |
this.Users = repoFactory.Create<Entities.User>(new RepositoryOptions(connectionString, dbName,"users") ); | |
this.Tags = repoFactory.Create<Entities.Tag>(new RepositoryOptions(connectionString, dbName, "tags")); | |
this.Taxonomies = repoFactory.Create<Entities.Taxonomy>(new RepositoryOptions(connectionString, dbName, "taxonomies")); | |
} | |
public IRepository<Entities.Post> Posts { get; private set; } | |
public IRepository<Entities.User> Users { get; private set; } | |
public IRepository<Entities.Tag> Tags { get; private set; } | |
public IRepository<Entities.Taxonomy> Taxonomies { get; private set; } | |
} |
nice catch, thanks!
On line one, it should be
public class DbContext : IDbContext
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line one, it should be
public class DbContext : IDbContext