Skip to content

Instantly share code, notes, and snippets.

@timemaster67
Created October 25, 2021 04:11
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 timemaster67/6135f0a04225d348b598187e0c04d88d to your computer and use it in GitHub Desktop.
Save timemaster67/6135f0a04225d348b598187e0c04d88d to your computer and use it in GitHub Desktop.
LiteDbExtension
internal static class LiteDbExtension
{
internal static void AddLiteDbRegistries(this IServiceCollection collection)
{
collection.AddTransient<LiteDB.ILiteCollection<Persistence.Entity.xxxxxx>>(serviceProvider =>
{
var database = serviceProvider.GetRequiredService<LiteDB.LiteDatabase>();
return database.GetCollection<Persistence.Entity.xxxxxx>();
});
}
internal static void AddLiteDbRegistries<T>(this IServiceCollection collection)
{
collection.AddTransient<LiteDB.ILiteCollection<T>>(serviceProvider =>
{
var database = serviceProvider.GetRequiredService<LiteDB.LiteDatabase>();
return database.GetCollection<T>();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment