In Microsoft Tutorial that explain How to Create a web API with ASP.NET Core and MongoDB https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-2.2&tabs=visual-studio
They have one Collection in MongoDB "Books", and when we configure connection to connect to this collection we add some codes in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.Configure<BookstoreDatabaseSettings>(
Configuration.GetSection(nameof(BookstoreDatabaseSettings)));
services.AddSingleton<IBookstoreDatabaseSettings>(sp =>
sp.GetRequiredService<IOptions<BookstoreDatabaseSettings>>().Value);
services.AddSingleton<BookService>();
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
My question: What if I wan to manipulate with multi collections rather than one "Books"? If I have 3 collections: Books, Anthers and Libraries, Should I add
services.AddSingleton<BookService>();
services.AddSingleton<AntherService>();
services.AddSingleton<LibraryService>();
Also what about 20 collections?