I am trying to create a custom loader for a bag that I have on an Nhibernate object using SQL 2005 stored procedure.
Both the parent object and the objects in the bag are loaded using stored procedures (they don't map to actual tables).
The problem I have is that I need to be able to pass parameters into the loader for the bag. The parameters are property values from the parent object. Any suggestions on how to do this?
Right now I am lazy-loading the collection, but I could just as easily load when the parent object is loaded. Would that be the way to go?
For whatever reason, I couldn't get the whole hbm file to paste into the body of this submission, but here is the bag and named query configuration...
<bag name="OrdersByProducts" lazy="true" inverse="true">
<cache usage="nonstrict-read-write" />
<key column="ID" />
<one-to-many class="Domain.ECommerce.Reports.OrdersByProductReport, Domain" />
<loader query-ref="ECOM_OrdersByProductsReport" />
</bag>
</class>
<sql-query name="ECOM_OrdersByProductsReport">
<return alias="report" class="OrdersByProductReport" >
<return-property name="ID" column="ID"/>
<return-property name="ReportingTimePeriod" column="ReportingTimePeriod"/>
<return-property name="StartDate" column="StartDate"></return-property>
<return-property name="EndDate" column="EndDate"></return-property>
<return-property name="ProductName" column="ProductName"></return-property>
</return>
exec dbo.ECOM_OrdersByProductsReport @StartDate = :StartDate, @EndDate = :EndDate, @TimePeriod = :TimePeriod
</sql-query>