c# - Can Automapper be used in a console application? -



c# - Can Automapper be used in a console application? -

is possible utilize automapper in console application?

its getting started page suggests bootstrapper class called application start up, there no farther details class add together , phone call main().

how go using in simple console app?

you can initialize automapper in console startup, there's no limitations; application_start startup place web programme in .net/iis, ie code called once. configuration must phone call @ start of web project goes in method.

edit comment: if don't want create mappings on fly, rather have place initialize mappings, create function called initializeautomapper , create mapper.configure<x, y> calls in here. in main() method, phone call function. there lots of ways handle configuration, simpler way handle it.

code sample

class programme { static void main(string[] args) { // app starting here initializeautomapper(); // we're configured, let's go! dostuff(); } static void initializeautomapper() { automapper.mapper.createmap<typea, typeb>(); automapper.mapper.createmap<typec, typed>(); automapper.mapper.createmap<typee, typef>(); } }

c# .net console-application automapper

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -