liveBook · Manning

UseLamar()

As explained in ASP.NET Core in Action, 3e

UseLamar() is an ASP.NET Core hosting extension method that configures Lamar as the application's dependency injection container.

UseLamar() configures Lamar as the dependency injection container for an ASP.NET Core application. Install Lamar.Microsoft.DependencyInjection, call the method on builder.Host, and register services inside its lambda. section 31.3

The configuration supports several responsibilities:

  • Add ASP.NET Core services such as authorization and controllers through Lamar's ServiceRegistry. section 31.3
  • Use AddControllersAsServices() when MVC controller dependencies are registered with Lamar. section 31.3
  • Scan assemblies and register concrete classes that follow default service-naming conventions. section 31.3

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains package installation, host configuration, service registration, conventions, scanning, and controller activation caveats.
Examples
Uses Program.cs configuration with authorization, controllers, AddControllersAsServices(), and default-convention assembly scanning.
What it assumes
Assumes an ASP.NET Core application using WebApplicationBuilder and requires the Lamar.Microsoft.DependencyInjection package.
What you can do after
Configure an ASP.NET Core application to resolve services and controller dependencies through Lamar.
How it connects
Connects ASP.NET Core dependency injection, WebApplicationBuilder, ServiceRegistry, IServiceCollection, MVC controllers, and assembly scanning.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.