Skip to main content

Estou tendo problemas ao mapear a Interface IClienteRepositoryInterface IClienteRepository com a classe ClienteRepositoryClienteRepository. Ao compilar a aplicação, aparece este erro:

"exception {"To be able to use the Lifestyle.Scoped property, please ensure that the container is configured with a default scoped lifestyle by setting the Container.Options.DefaultScopedLifestyle property with the required scoped lifestyle for your type of application. See: https://simpleinjector.org/lifestyles#scoped"} System.InvalidOperationException"

"exception {"To be able to use the Lifestyle.Scoped property, please ensure that the container is configured with a default scoped lifestyle by setting the Container.Options.DefaultScopedLifestyle property with the required scoped lifestyle for your type of application. See: https://simpleinjector.org/lifestyles#scoped"} System.InvalidOperationException"

Alguém sabe comoComo resolver?

public static Container RegisterServices(Container container)
        {
            //Domain to Repository

            container.Register<IClienteRepository, ClienteRepository>(Lifestyle.Scoped);

            return container;
        }

 public interface IClienteRepository : IRepository<Cliente>
    {
    }

public class ClienteRepository : Repository<Cliente>, IClienteRepository
    {
        public ClienteRepository(SistemaComercialContext context)
            :base(context)
        {

        }
    }

 
public static Container RegisterServices(Container container)
    {
        //Domain to Repository

        container.Register<IClienteRepository, ClienteRepository>(Lifestyle.Scoped);

        return container;
    }

public interface IClienteRepository : IRepository<Cliente>
    {
    }

public class ClienteRepository : Repository<Cliente>, IClienteRepository
    {
        public ClienteRepository(SistemaComercialContext context)
            :base(context)
        {

        }
    }

Estou tendo problemas ao mapear a Interface IClienteRepository com a classe ClienteRepository. Ao compilar a aplicação, aparece este erro:

"exception {"To be able to use the Lifestyle.Scoped property, please ensure that the container is configured with a default scoped lifestyle by setting the Container.Options.DefaultScopedLifestyle property with the required scoped lifestyle for your type of application. See: https://simpleinjector.org/lifestyles#scoped"} System.InvalidOperationException"

Alguém sabe como resolver?

public static Container RegisterServices(Container container)
        {
            //Domain to Repository

            container.Register<IClienteRepository, ClienteRepository>(Lifestyle.Scoped);

            return container;
        }

 public interface IClienteRepository : IRepository<Cliente>
    {
    }

public class ClienteRepository : Repository<Cliente>, IClienteRepository
    {
        public ClienteRepository(SistemaComercialContext context)
            :base(context)
        {

        }
    }

 

Estou tendo problemas ao mapear a Interface IClienteRepository com a classe ClienteRepository. Ao compilar a aplicação, aparece este erro:

"exception {"To be able to use the Lifestyle.Scoped property, please ensure that the container is configured with a default scoped lifestyle by setting the Container.Options.DefaultScopedLifestyle property with the required scoped lifestyle for your type of application. See: https://simpleinjector.org/lifestyles#scoped"} System.InvalidOperationException"

Como resolver?

public static Container RegisterServices(Container container)
    {
        //Domain to Repository

        container.Register<IClienteRepository, ClienteRepository>(Lifestyle.Scoped);

        return container;
    }

public interface IClienteRepository : IRepository<Cliente>
    {
    }

public class ClienteRepository : Repository<Cliente>, IClienteRepository
    {
        public ClienteRepository(SistemaComercialContext context)
            :base(context)
        {

        }
    }
Fonte Link
Master JR
  • 1,9mil
  • 1
  • 20
  • 51

Dúvida sobre como Mapear uma Interface com uma classe - SimpleInjector

Estou tendo problemas ao mapear a Interface IClienteRepository com a classe ClienteRepository. Ao compilar a aplicação, aparece este erro:

"exception {"To be able to use the Lifestyle.Scoped property, please ensure that the container is configured with a default scoped lifestyle by setting the Container.Options.DefaultScopedLifestyle property with the required scoped lifestyle for your type of application. See: https://simpleinjector.org/lifestyles#scoped"} System.InvalidOperationException"

Alguém sabe como resolver?

public static Container RegisterServices(Container container)
        {
            //Domain to Repository

            container.Register<IClienteRepository, ClienteRepository>(Lifestyle.Scoped);

            return container;
        }

 public interface IClienteRepository : IRepository<Cliente>
    {
    }

public class ClienteRepository : Repository<Cliente>, IClienteRepository
    {
        public ClienteRepository(SistemaComercialContext context)
            :base(context)
        {

        }
    }