Skip to main content
1 de 2
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)
        {

        }
    }

Master JR
  • 1,9mil
  • 1
  • 20
  • 51