i have wcf project multiple layers ( , dto object ) :
-service ( wcf host )
-business layer ( or domain layer )
-data access layer ( using entity framework )
to retrieve database informations , want use automapper map entity object dto object .
but if configure mapping in global.asax , problem : service layer not reference data access layer (and dont want this).
how can ?
thanks lot.
let's assume you're using automapper 5.1, includes profile scanning. first, you'd want put configuration profiles @ appropriate places:
public class entitytodtoprofile : profile { public entitytodtoprofile() { createmap<entity, dto>(); } }
next, in wcf app, wherever app startup is, you'll initialize automapper, passing in assembly names scan profiles:
mapper.initialize(cfg => { cfg.addprofiles(new [] { "mylayeredapp.bll", "mylayeredapp.dal", "mylayeredapp.service" }); });
automapper scan assemblies profiles, , register them in configuration. make sure call mapper.initialize once @ startup, other app-wide configuration.
or, create 1 wcf project, collapse projects one, , use folders organization instead of this. works.
Comments
Post a Comment