Click here to Skip to main content
13,195,026 members (91,148 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm working on a small simple MVC 3 project. I have three layers basically.

Layer One - UI - Controllers, Views
Layer Two - Models
Layer Three - Business rules.

With Layer One - UI - I created a reference to Models and Business Rules.

With Business Rules, I created a series of Interfaces and I applied those interfaces to the Controllers in UI. I used Ninject Dependency Injection.

Simple so far - the basic idea works but this is where I'm stuck.

I created a WCF as a separate project. The WCF works just fine in preliminary tests but I came to the conclusion that I'm not doing a true separation of code in the controller.

In Layer One (UI) I added a web reference to the WCF and brought back a list of items in a simple Controller command like this:

Using (WCF w = new WCF()
..flood the view. Blah blah.

It works but I know my gut is telling me that this is the "wrong approach" when it comes to true coding of separation of layers.

I'm struggling with the idea of passing the reference to the WCF to Layer Two (business rules) via Injection. (Ninject Dependency Injection)

Basically, I could add a reference to the UI FROM the business layer but I already added a reference to the Business Layer from the UI - this would cause a "circular reference" which I suspect is a no-no.

I've been trying to find articles to tackle this method but alas...

Can anyone shed some light on this as to what articles I should review?

Posted 4-Jan-13 7:51am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The WCF object should be hidden from the presentation layer, I think. It should be in the data layer, it's a way of getting access to data entity objects.

I've used Ninject, and discarded it. Your controllers can get passed entity objects instantiated by your own layer within MVC, and that's all I've never needed.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thanks, Christian.

If we created a data layer and created a web reference in that layer, what do we do about the config.sys from the data layer regarding the WCF?

And from what I understand I can create a reference from the biz layer to the data layer?

Out of curiosity, why did you discard Ninject?


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171018.2 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100