Created
January 19, 2017 22:11
-
-
Save alikrc/3297df660fd235ae84ab943a62245a16 to your computer and use it in GitHub Desktop.
DatabaseFactory class implementation
This file contains hidden or 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 interface IDatabaseFactory | |
{ | |
HIDSDbContext Get(); | |
} | |
public class DatabaseFactory : IDisposable, IDatabaseFactory | |
{ | |
private DbContext _context; | |
public DbContext Get() | |
{ | |
return _context ?? (_context = new DbContext()); | |
} | |
public void Dispose() | |
{ | |
if (_context != null) | |
_context.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment