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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:30:35+00:00 2026-05-17T00:30:35+00:00

I’ve been slowly teaching myself the fundamentals of interface driven programming and I’m struggling

  • 0

I’ve been slowly teaching myself the fundamentals of interface driven programming and I’m struggling to get my head round a few principles regarding inversion of control specifically with Ninject.

Lets say I have a concrete model class as follows…

 public sealed class Host : EntityAuditable<Host, Guid>

I have a base class which defines methods for the model like this….

public abstract class EntityAuditable<T, TKey> : 
    IEntity, 
    IDisposable, 
    IComparable<EntityAuditable<T, TKey>> 
    where T : EntityAuditable<T, TKey>, new()

IEntity is a very simple interface that defines an object property ‘Id’.

Now the constructor for my Host class would be as follows….

public Host(IService<Host> service)
{
    this.service = service;
    this.id = Guid.NewGuid();
}

Where the IService implementation provides methods to persist objects to the repository specific to the service.

What I would like to do is provide some static methods in my base class so that I can write code like

Host.LoadAll(); 

and know that my bindings will be injected correctly. My implementation in the base class would be something similar to this…

   public static IList<T> LoadAll()
    {
        T instance = new T();
        List<T> instances = new List<T>(instance.DataSelectAll());
        // Clean up the instance.
        instance.Dispose();
        return instances;
    }

Is this possible or am I doing something fundamentally wrong?

Does Ninject work in a way that it knows it should be calling my parameterized constructor when I call new T() ?

The examples I have found in the documentation (Which is sadly out of date) use the kernel to create the object but I don’t want to have kernel creating code littered about in my models.

I’d be doing all my binding in my Global.ascx file.

  • 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-17T00:30:35+00:00Added an answer on May 17, 2026 at 12:30 am

    In answer to my own question it turns out that my approach was incorrect.

    Stripping out the static methods and using my mvc controllers for the business logic led to far better separation and much cleaner and more maintainable code. Binding everything with ninject was far easier then.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.