Skip to content

xinix00/RavenDB.AspNetCore.DependencyInjection

 
 

Repository files navigation

RavenDB.AspNetCore.DependencyInjection

Dependency Injection package for using RavenDB with ASP.NET Core.

Docker Stars Docker Pulls

This package handles the injection of DocumentSession( or AsyncDocumentSession) for you and while keeping track and managing the DocumentStore(s) for you.

Getting Started:

Install the RavenDB.AspNetCore.DependencyInjection library through NuGet.

    Install-Package RavenDB.AspNetCore.DependencyInjection
    
    Or
    
    Install-Package RavenDB.AspNetCore.DependencyInjection -Pre

Usage:

Add this to your Startup.cs:

public IServiceProvider ConfigureServices(IServiceCollection services)
{
...
	
  services.AddRaven(
      options =>
      {
          options.DefaultServer = "Main";
          options.AddServer("Main", new RavenServerOptions()
          {
              Url = "{server url}",
              DefaultDatabase = "{default database}"
          });
      }).AddAsyncSession();
	
...
}

Now you can use the standard injection syntax to get you're session or the raven manager:

public class HomeController
      : Controller
  {
      private readonly IAsyncDocumentSession _session;
      private readonly IRavenManager _ravenManager;

      public HomeController(
          IAsyncDocumentSession session,
          IRavenManager ravenManager)
      {
          _session = session;
          _ravenManager = ravenManager;
      }
  }

User Feedback

Issues

If you have any problems with or questions about this image, please contact us through a GitHub issue.

About

Dependency Injection package for using RavenDB with ASP.NET Core.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.3%
  • Batchfile 2.7%