0

I've trying to do the following with AutoFac (samples taken from here and here):

builder.Register(c => c.Resolve<IDocumentStore>().OpenSession())          
       .InstancePerLifetimeScope();

problem is, with the current release of AutoFac, i get a compile error with c.Resolve

Can someone please tell me how I can register an IDocumentSession, which is given to me by an IDocumentStore instance OpenSession() method.

enter image description here

Community
  • 1
  • 1
Pure.Krome
  • 82,011
  • 105
  • 379
  • 615
  • 2
    that issue is to do with R#, delete your R# cache and re-open the solution. If you ever come across that problem, and the project builds fine but you get warnings regardless, R# issue. – Phill Mar 10 '13 at 05:41

1 Answers1

2
builder.RegisterInstance(documentStore).As<IDocumentStore>();

builder.Register(x => x.Resolve<IDocumentStore>().OpenSession())
       .As<IDocumentSession>()
       .InstancePerLifetimeScope();
Phill
  • 17,724
  • 6
  • 55
  • 101