views:

86

answers:

1

Hi all,

Should I be doing my automapping in my service layer or at my controller?

I like the Idea of Repository - Raw data IQueryable type stuff with full domain(type) objects. Service layer - Paged, Ordered, Filtered, Automapped View model to return Controller - Push the view with the correct model

But having seen some nice stuff with ActionFilters and attributes I'm wondering if a better approach would be

Repository - Raw data IQueryable type stuff with full domain(type) objects. Service layer - filtered, paged data Domain objects Controller - Automapping the service layer data and pushing the view.

Any thoughts on this would be greatly appreciated

+2  A: 

You may have seen this article: http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/06/29/how-we-do-mvc-view-models.aspx

I found this interesting and I plan to use it in my next project. It appears that you can still keep your controller thin and decorate your action methods with an automapper.

It sounds like this is what you're planning to do and it sounds like a good approach.

malckier
Hahahaha yeah that's the article that I had read.. Glad where on the same wave length. I'm just struggling with how to separate things. It seems pointless using a service layer if I'm doing all my mapping etc on my controller. At the minute my service layer calls my repository and passes back a mapped up, paged view model to the controller but this approach of mapping seems appealing, but what does my service layer pass back now? Just a paged list ready to map? I had issues with that before.
Andyroo
Thanks for the link to the article. Very informative. Backs up what I've been doing recently and gives me some ideas for using ActionFilters...
Bryce Fischer