Pronounced "Sharp Architecture," this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate. The primary advantage to be sought in using any architectural framework is to decrease the code one has to write while increasing the quality of the end product. A framework should enable developers to spend little time on infrastructure details while allowing them to focus their attentions on the domain and user experience. Accordingly, S#arp Architecture adheres to the following key principles: Focused on Domain Driven Design Loosely Coupled Preconfigured Infrastructure Open Ended Presentation The overall goal of...
Interessante serie di screencast su NHibernatehttp://www.summerofnhibernate.com/Diego
Problema
Trasformare un resultset generico in una lista tipizzata di DTO (quindi non una entity del Domain Model).
Soluzione
Utilizzare ResultTransformer di NHibernate.
Quest'interfaccia consente di specificare una classe di output sulla quale verrà "mappatio" il resultset.
Esempio
File di mapping
<sql-query name="GetCashFlowMainData">
<return-scalar column="Id" type="Int32" />
<return-scalar column="ReportType" type="Int32"...
Snippet per verificare che lo schema del database corrisponda a quello descritto dal nostro Domain Model.
[Test]
public void AllNHibernateMappingAreOkay()
{
...