Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:12:16+00:00 2026-06-02T00:12:16+00:00

I have a type IRoleRepository which accepts a constructor argument database which accepts a

  • 0

I have a type IRoleRepository which accepts a constructor argument “database” which accepts a type of IDbRepository which itself takes a constructor argument “ConnectionStringName”. I have a dependency resolver which has a GetService method and while the following code works I was hoping there would be better way to do this at Bind time vs at Get time with Ninject 3.0. Note I may have multiple IDBRepository instances each with their own “ConnectionStringName”.

_repository = EngineContext.Current.GetService<IRoleRepository>(
                        new ConstructorArgument("database",
                            EngineContext.Current.GetService<IDbRepository>(
                                new ConstructorArgument(SystemConstants.ConnectionStringName, SystemConstants.ConfigurationDatabase))));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:12:19+00:00Added an answer on June 2, 2026 at 12:12 am

    OK I believe I found what I wanted:

    By using this at Bind Time:

                Bind<IDbRepository>().To<SqlServerRepository>()
                .WhenInjectedInto<IRoleRepository>()
                .WithConstructorArgument(SystemConstants.ConnectionStringName, SystemConstants.ConfigurationDatabase);
    

    This allows me to use this at Get time:

    _repository = EngineContext.Current.GetService<IRoleRepository>();
    

    This of course means I can now vary the constructor argument for IDbRepository based upon the more specific repository which the IDbRepository is being injected. eg:

                Bind<IDbRepository>().To<SqlServerRepository>()
                .WhenInjectedInto<ITimerJobStore>()
                    .WithConstructorArgument(SystemConstants.ConnectionStringName, SystemConstants.ConfigurationDatabase);
    
            Bind<ITimerJobStore>().To<TimerJobSqlStore>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struct which has several arrays within it. The arrays have type
I have a Type MenuItem that has one-to-many relationship with itself through Children property.
I have a type of object called Bin , which has a hashtable field
I have a type that has index properties which I want to access via
I have type classes, for all of which I would like to have some
Scala doesn't have type-safe enum s like Java has. Given a set of related
Let's say I have type A, and a derived type B. When I perform
In C# we have Type.FullName and Type.Name for getting the name of a type
The following code fails in 'Evaluate' with: This expression was expected to have type
I have a type and an interface and I need to verify that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.