![]() Simple Injector's documentation lists a good example how you can use both Register and Collection.Register side by side to get it working ( source). This means that you'll either have to change the constructor to accept IEnumerable or register a non-collection IDataBaseSqlServerDapper Meaning that your DI does not know how to resolve a single IDataBaseSqlServerDapper, only a collection of them. In the second case you are registering multiple services of type IDataBaseSqlServerDapper. ![]() ![]() In the existing case you specify that type IDataBaseSqlServerDapper can be used for injection, which in turn gets properly injected into your object (in this case a class that implements IDapperQueryFactory). There is, however, a registration for IEnumerable Did you mean to depend on IEnumerable? Please ensure IDataBaseSqlServerDapper is registered, or change the constructor of DapperQueryFactory. The constructor of type DapperQueryFactory contains the parameter with name 'dataBaseSqlServerDapper' and type IDataBaseSqlServerDapper that is not registered. Creating the instance for type IDapperQueryFactory failed. SqlServerDb, AdmbbDd and Connection are classes that contains the names of the connection strings. () => new PetaPoco.Database(Connection.SurveyEngine) () => new OrmLiteConnectionFactory(SqlServerDb.ConnectionString(), () => new DataBaseSqlServerDapper(SqlServerDb.ConnectionString(), These are the existing registrations for the main db: _container.Register( I need to make an endpoint to get info from a different db but I don't know how to register a new connection. I'm working with an existing Web Api that uses Simple Injector to register a single database connection.
0 Comments
Leave a Reply. |