Skip to content

Instantly share code, notes, and snippets.

@codehaks
Created October 1, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codehaks/12b528749e07d53a7451f14d9162dada to your computer and use it in GitHub Desktop.
Save codehaks/12b528749e07d53a7451f14d9162dada to your computer and use it in GitHub Desktop.
LiteDb Context
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