I am a bit new to StructureMap's IoC (and IoC in general). From examples, I have my stuff set up like this:
DefaultRegistry:
public DefaultRegistry() {
Scan(
scan => {
scan.TheCallingAssembly();
scan.WithDefaultConventions();
scan.With(new ControllerConvention());
});
For<IRepository>().Use<Repository>().Ctor<string>("connectionString").Is(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
//For<IExample>().Use<Example>();
}
Then, in each controller that any Action needs the database, I have:
private IRepository _Repository;
public TipsController(IRepository repository)
{
_Repository = repository;
}
When I need to use it, I just do:
data.Information = await _Repository.GetInformationAsync();
When I used ADO.NET, I always had a using statement around everything. I've seen examples of Entity Framework that utilizes the using statement. But, when using EF in conjunction with StuctureMap, do I need to somehow wrap a using statement around it? If so, how do I?