Created
October 1, 2018 16:56
-
-
Save codehaks/12b528749e07d53a7451f14d9162dada to your computer and use it in GitHub Desktop.
LiteDb Context
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
using LiteDB; | |
using Microsoft.Extensions.Options; | |
using System; | |
namespace BugPages.Common | |
{ | |
public class LiteDbContext | |
{ | |
public readonly LiteDatabase Context; | |
public LiteDbContext(IOptions<LiteDbConfig> configs) | |
{ | |
try | |
{ | |
var db = new LiteDatabase(configs.Value.DatabasePath); | |
if (db != null) | |
Context = db; | |
} | |
catch (Exception ex) | |
{ | |
throw new Exception("Can find or create LiteDb database.", ex); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment