Note that there are some explanatory texts on larger screens.

plurals
  1. POISession/UnitofWork in Service Layer within Windsor tutorial
    primarykey
    data
    text
    <p>I'm trying to build a real-world app using <a href="http://docs.castleproject.org/Windsor.Windsor-tutorial-ASP-NET-MVC-3-application-To-be-Seen.ashx" rel="nofollow">this tutorial</a> as a basis for the framework. I understand MVC, but am new to the whole IOC/NHibernate world. After reading a few Q&amp;A here on SO, I am thinking of adding a Service layer between the controller and the repository as I'll be adding some business rule validations down the line. </p> <p>The source on github also has a 'ServiceInstaller' that proved really useful as it allows me to add any services to the application i.e. </p> <pre><code>public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register(AllTypes.FromThisAssembly().Pick() .If(Component.IsInSameNamespaceAs&lt;SectionService&gt;()) .Configure(c =&gt; c.LifeStyle.Transient) .WithService.DefaultInterface()); } </code></pre> <p>My question is specific to this tutorial, and its basically that I'm not sure if the ISession (which is the UoW) is passed from the Service layer to the Repository, or if there's another approach.</p> <p>Here's what I have so far:</p> <pre><code>// Controller public class SectionsController : Controller { public ILogger Logger { get; set; } private readonly ISectionService sectionService; public SectionsController(ISectionService sectionService) { this.sectionService = sectionService; } public ActionResult Index() { return View(sectionService.FindAll()); } // other action methods } // Service Layer public class SectionService : ISectionService { private ISectionRepository repository; public SectionService(ISession session) { this.repository = new SectionRepository(session); } public IQueryable&lt;Section&gt; FindAll() { return repository.FindAll(); } // other methods } // Repository public class SectionRepository : ISectionRepository { private readonly ISession session; public SectionRepository(ISession session) { this.session = session; } public IQueryable&lt;Section&gt; FindAll() { return session.QueryOver&lt;Section&gt;().List().AsQueryable(); } // other CRUD methods } </code></pre> <p>Is this correct way to implement this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload