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

1
  • 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. Commented Mar 10, 2013 at 5:41

1 Answer 1

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

builder.Register(x => x.Resolve<IDocumentStore>().OpenSession())
       .As<IDocumentSession>()
       .InstancePerLifetimeScope();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.