Skip to content

Instantly share code, notes, and snippets.

@DalSoft
Created April 11, 2012 15:43
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 DalSoft/2360124 to your computer and use it in GitHub Desktop.
Save DalSoft/2360124 to your computer and use it in GitHub Desktop.
MVC – Get RavenDB up and running in 5 minutes using Ninject
using Ninject;
using Ninject.Modules;
using Ninject.Web.Common;
using Raven.Client;
using Raven.Client.Embedded;
using Raven.Database.Server;
namespace RavenDBInFiveMinutes
{
public class RavenDBNinjectModule : NinjectModule
{
public override void Load()
{
Bind<IDocumentStore>()
.ToMethod(context =>
{
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
var documentStore = new EmbeddableDocumentStore { DataDirectory = "App_Data", UseEmbeddedHttpServer = true, };
return documentStore.Initialize();
})
.InSingletonScope();
Bind<IDocumentSession>().ToMethod(context => context.Kernel.Get<IDocumentStore>().OpenSession()).InRequestScope();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment