Created
October 25, 2021 04:11
-
-
Save timemaster67/6135f0a04225d348b598187e0c04d88d to your computer and use it in GitHub Desktop.
LiteDbExtension
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
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