Sunday, 15 February 2015

ASP.NET Mvc - AutoMapper Best Practice - Performance -


I have not seen the automation source code yet, but in my solution the API controller is about to make some changes and one The idea was.

The way I like the code, to keep my controller's methods as brief as possible, for example I'm using a common exception feature to capture try {} { } Scenarios.

So the only relevant code for the controller action is in the verb method only.

So I came to a situation where I needed to create a automator map for a method I was initially thinking that I would add the controller constructor like this I will (as I did before). Available immediately after

However, as the controller grows above this pattern, every request is created and destroyed in view of the very unnecessary Automaker

Controllers, It can be expensive.

What are some recommendations about this? Consider Automaker is used statically, I was thinking that this intern is beyond the internal request and before implementing the CreateMap () each time Does internal check for an existing Mac?

You should create your map ( CreateMap ) once per app in the domain , Ideally when this domain starts ( Application_Start ).

No comments:

Post a Comment