entity framework 5 - EntityFramework 5.0 with CastleWindsor -


as ef 5.0 having unitofwork pattern implemented want instead of creating own iunitofwork classes maintaining transactions. of examples found on internet using separate unitofwork instead of ef directly.

i'm trying implement using ioc (castle windsor). please provide samples or direction on implementing this.

thanks in advance

sai

you didn't provide details current windsor setup or uow looks in ef5 (i don't use it), based on [1] appears have iunitofwork interface implemented on db context class. appears pretty straightforward leverage in dependency injection pattern driven windsor. you'll first want register iunitofwork interface , implementation container. there's variety of ways register components in windsor. prefer installers [2]... you'll end this:

public class yourinstaller : iwindsorinstaller {    public void install(iwindsorcontainer container, iconfigurationstore store)    {       container.register(component.for<iunitofwork>().implementedby<yourdbcontext>());    } } 

then have injected application's services in fashion such as:

public class yourservice {     public yourservice(iunitofwork uow)     {        // rock out     } } 

[1] http://dumians.wordpress.com/2013/04/13/how-to-use-repository-and-unit-of-work-patterns-with-entity-framework/ [2] http://docs.castleproject.org/default.aspx?page=installers&ns=windsor&aspxautodetectcookiesupport=1


Comments