Skip to content

Instantly share code, notes, and snippets.

@detroitpro
Last active November 14, 2016 19:25
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 detroitpro/d6f05342f6b9817ed3269b0a6449c957 to your computer and use it in GitHub Desktop.
Save detroitpro/d6f05342f6b9817ed3269b0a6449c957 to your computer and use it in GitHub Desktop.
PerWebRequest using external container
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
public class Register
{
public Register(){
//These two registrations provide the same functionality.
//ASP.NET (4.6.x)
container.Register(Component.For<MyEntityFrameworkContext>)
.ImplementedBy<MyEntityFrameworkContext>()
.LifestylePerWebRequest());
//DotNet Core
container.Register(Component.For<MyEntityFrameworkContext>)
.ImplementedBy<MyEntityFrameworkContext>()
.LifestyleCustom<MsScopedLifestyleManager>());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment