Note that there are some explanatory texts on larger screens.

plurals
  1. POusing ninject with layered asp.net mvc application and Entity Framework edmx
    primarykey
    data
    text
    <p>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.</p> <p>Right now I have 4 layers: </p> <ul> <li>DataAcces (contains edmx and repositories, which I will show later)</li> <li>BusinessLogic (standard BL)</li> <li>Common (models)</li> <li>Gui (a mvc4 project)</li> </ul> <p>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.<br /> Now I don't want that here. I'm not using WCF. I also don't want to call my DataAccess in my Gui.</p> <p>Since I said I'd show some code for insight:</p> <p>Repository in DataAccess</p> <pre><code>public class Repo: IRepo { Entities context = new Entities(); public IQueryable&lt;PictureSource&gt; PictureSource { get { return context.PictureSource; } } } </code></pre> <p>my IRepository is just this:</p> <pre><code>public interface IRepository { IQueryable&lt;PictureSource&gt; PictureSource { get; } } </code></pre> <p>What I want to be able to do is in my BusinessLogic. I want to be able to do the following:</p> <pre><code>public List&lt;Picture&gt; GetStuff(IRepository Repo) { //code } </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload