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 535825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:45:27+00:00 2026-05-13T09:45:27+00:00

I have an application that is currently divided into Service and Data Access Layers

  • 0

I have an application that is currently divided into Service and Data Access Layers (with an MVC Layer in the works). I’m trying to reduce the amount of boilerplate Ninject code required in my classes.

My first idea was a base class for each Business Object type (i.e. UserBase) that would be extended by UserService and UserDAO. Unfortunately, that would prevent me from extending any other classes (i.e. a AbstractService class extended by all Service implementations, an AbstractDAO class, etc).

My second idea was a simple factory to return the IKernel for various IModule implementations passed to it. Unfortunately, each class would need an IKernel member variable, but it solved the problem and allowed AbstractService and AbstractDAO to be created.

    class NinjectKernelFactory
    {
        private NinjectKernelFactory()
        {
        }

        public static IKernel getKernel(params IModule[] modules)
        {
            IKernel kernel = new StandardKernel(modules);
            return kernel;
        }
    }

Are there any other ideas for optimizing my use of Ninject?

  • 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-13T09:45:27+00:00Added an answer on May 13, 2026 at 9:45 am

    Yes, using property injection is a good way to go here. And if you want to get an even nicer design, you can even use ninject itself to create the controllers by creating a custom ControllerFactory and using the kernel to get the instance controller. That way, the controller will have been initialized with the IKernel property already:

    http://nayyeri.net/custom-controller-factory-in-asp-net-mvc

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

Sidebar

Related Questions

I currently have an MS Access application that connects to a PostgreSQL database via
I have a classic ASP application that I've been constantly trying to modularize. Currently,
I have an application that is currently running against a 32-bit SQL Server 2005
I have a web application that currently sends emails. At the time my web
I have a web application that's branded according to the user that's currently logged
I currently have an application that gets hit with over 20,000 users daily and
Currently I have an application that receives an uploaded file from my web application.
I have a Windows GUI application that's using the Qt framework (currently version 3.3.5,
We currently have a quite complex business application that contains a huge lot of
I currently have a database that gets updated from a legacy application. I'd like

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.