I would put it with your application's initialization code that sets up your IoC container, such as Application_Start in the ASP.NET world or Main() in WinForms.
Alternatively, you could create a new type called MapperWrapper that implements ISqlMapper but calls Configure() when it is first instanced and passes all of the method calls into the mapper instance that it is wrapping; then you inject that wrapper implementation into your DAOs. This way, the assembly containing your Main() or Application_Start wouldn't need to reference an iBATIS assembly. public class MapperWrapper : ISqlMapper { private ISqlMapper mapper; public MapperWrapper() { this.mapper = ConfigureTheMapper(); } public int Insert(string map, object param) { return this.mapper.Insert(map, param); } // ... etc ... } For what it's worth, since the mapper is a dependency of the repository, I'm not sure what "bang for the buck" you would get for doing this, as I've never seen much value in unit testing (vs integration testing against actual test database) an actual DAO implementation. Good luck! V/R, Nicholas Piasecki -----Original Message----- From: Sal Bass [mailto:salbass...@hotmail.com] Sent: Monday, May 11, 2009 12:17 PM To: user-cs@ibatis.apache.org Subject: Bootstrapping Ibatis How do you guys inject the mapper via IoC into your DAOs / Repositories? I want to move away from the singleton approach, and I know using IoC tool I can define the mapper's scope as a singleton that way, but where would I put the put DomSqlMapBuilder.Configure(sqlMapConfig) code that needs to be called the first time an instance is created? _________________________________________________________________ Windows LiveT: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009