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

  • SEARCH
  • Home
  • 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 841217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:45:22+00:00 2026-05-15T05:45:22+00:00

I need to inject generic repositories (IRepository) into my classes’ constructors but I dont

  • 0

I need to inject generic repositories (IRepository) into my classes’ constructors but I dont know how to do it with the new DSL in structuremap 2.6, does anyone know how?

  • 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-05-15T05:45:22+00:00Added an answer on May 15, 2026 at 5:45 am

    This can be done with just one line of code in your configuration. Assuming you have this:

    Entities:
    – Customer
    – Order

    And have a generic repository model like this:

    • Repository : IRepository

    And have a app services that look like:

    public AppService(IRepository<Customer> custRepo, IRepository<Order> orderRepo)
    

    You would have something like this. Notice the bit about using the scanner to hook up your custom repositories.

    public class SmRegistry : Registry
        {
            public SmRegistry()
            {
                For(typeof (IRepository<>))
                    .Use(typeof (Repository<>));
    
                //using this will find any custom repos, like CustomerRepository : Repository<Customer>
                //Scan(scanner =>
                //         {
                //             scanner.TheCallingAssembly();
                //             scanner.ConnectImplementationsToTypesClosing(typeof (IRepository<>));
    
                //         });
            }
        }
    

    Assuming your Repositories are defined in some other assembly from your application, you can use Registries to hook it all together. Check out this post:

    http://blog.coreycoogan.com/2010/05/24/using-structuremap-to-configure-applications-and-components/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally when I need to inject one or more services into another service, I
DO I need to inject the JavaMail Objects into the application context and access
I need to inject Spring beans into a JSF (Primefaces) converter. I tried to
I currently have two branches, Parent(Main) and Child(Release). I need to inject a new
I need to Inject some global service (daoFactory) into EventListenet subscribed on PostUpdate event.
I'm using background page and I need to inject some code into current tab
I need to inject a custom, unique, static string into my .NET based EXE.
I need to inject a java.utils.Properties instance into one of my beans. Is there
I've created my own service and I need to inject doctrine EntityManager, but I
I need to inject a service based on domain property, so far I came

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.