maartenba/MvcSiteMapProvider

Autofac DI

lgoudriaan opened this issue · 0 comments

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?