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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:09:44+00:00 2026-06-12T01:09:44+00:00

I’m working in asp.net mvc 4 with Entity Framework 5 (with edmx). I’m trying

  • 0

I’m working in asp.net mvc 4 with Entity Framework 5 (with edmx). I’m trying to get Ninject to work correctly, but using the bindings has got me quite confused. I’ve seen Ninject being used before, but that was in a WCF project where the DI was being set in the WCF-layer.

Right now I have 4 layers:

  • DataAcces (contains edmx and repositories, which I will show later)
  • BusinessLogic (standard BL)
  • Common (models)
  • Gui (a mvc4 project)

Now here’s the tricky part: I want to use DI here. The way I saw it being used in my previous WCF-project was that my WCF-layer went to my DataAccess so I can use the kernel.bind.
Now I don’t want that here. I’m not using WCF. I also don’t want to call my DataAccess in my Gui.

Since I said I’d show some code for insight:

Repository in DataAccess

public class Repo: IRepo
    {
        Entities context = new Entities();

        public IQueryable<PictureSource> PictureSource
        {
            get { return context.PictureSource; }
        }
    }

my IRepository is just this:

public interface IRepository
    {
        IQueryable<PictureSource> PictureSource { get; }
    }

What I want to be able to do is in my BusinessLogic. I want to be able to do the following:

public List<Picture> GetStuff(IRepository Repo)
        {
          //code
        }

Now I’ve looked a lot on the internet. About 80% of the examples use Web Apim which is useless to me. The other 20% just seem to do whatever they want “because it’s just a demo” and violate Gui-BL-DA principle. I’ve seen examples consisting of a single layer to examples doing Business Logic in Data Access.
The ninject wiki also didn’t help me as I’m new to DI and I’ve only seen it being used in an existing application.

  • 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-12T01:09:45+00:00Added an answer on June 12, 2026 at 1:09 am

    Try to code using Poor-Man’s-DI. Inject your dependencies in your constructor!

    public class BusinessLogic
    { 
      private _repository;
    
      public BusinessLogic(IRepo repository) 
      { 
         _repository = repository;
      }
    
      public List<Picture> GetStuff()
      {
          _repository.PictureSource.Where(x=>x.Published == false);
      }
     }
    

    Once you have your codebase right, register your dependencies in Ninject. Ninject then takes care to inject your Repository to you BusinessLogic class.

    Please note that you have an IQueryable in your IRepo, which you should avoid (http://www.infoq.com/news/2012/03/IQueryable-api)

    Edit:
    This would be your solution structure and the references:

    MVC4 (GUI)
     -> DataAccess
     -> BusinessLogic
     -> Common
    
    You need to setup this references, to wire up your bindings.
    
    BusinessLogic
     -> Common (including your Interfaces!)
    
    DataAccess
     -> Common
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

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.