Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofac DI #461

Open
lgoudriaan opened this issue Mar 14, 2017 · 0 comments

Comments

@lgoudriaan
Copy link

commented Mar 14, 2017

Hello,

I'm receiving multiple errors with the message: "There is already an open DataReader associated with this Command which must be closed first." the error happens in a DynamicNodeProvider.

I guess it's a configuration problem, but I can't find the issue.

My boostrapper:
builder.RegisterType<UnitOfWork>().As<IUnitOfWork>().InstancePerLifetimeScope(); builder.RegisterType<DbFactory>().As<IDbFactory>().InstancePerLifetimeScope();

repositories and services are registered as InstancePerLifetimeScope()

My node provider:

public class VehicleDynamicNodeProvider : DynamicNodeProviderBase
{

private readonly IVehicleService _vehicleService;

public VehicleDynamicNodeProvider(IVehicleService vehicleService)
{
    _vehicleService = vehicleService;
}

public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
{
    var vehicles = _vehicleService.GetAllSiteMap(); // returns a list of vehicles as noTracking

    if (vehicles != null)
    {
        foreach (var vehicle in vehicles)
        {
            //removed for brevity
            yield return dynamicNode;
        }
    }
}

}

Does someone see the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.