Anyone have any sample code for populating a bag with a custom SQL
SELECT statement?  I need to be able to run a query using the object's
id and it should return a list of another type of object.

The mapping code below demonstrates sorta what I need to do but this
doesn't work.

Mapping Code:
<class name="Book" table="Devices">
    <id name="Id" type="Int32" column="Id" access="property">
      <generator class="identity">
        <param name="table">Books</param>
        <param name="column">Id</param>
      </generator>
    </id>
    <bag name="PagesInBook" inverse="true">
      <key></key>
      <one-to-many class="Pages"/>
      <loader query-ref="customLoader"/>
    </bag>
  </class>
<class name="Page" table="Pages">
    <id name="Id" type="Int32" column="Id" access="property">
      <generator class="identity">
        <param name="table">Pages</param>
        <param name="column">Id</param>
      </generator>
    <property name ="BookId" column="fkBookId"/>
    </id>
</class>
<sql-query name="customLoader">
    <load-collection alias="dev" role="Page"/>
    <![CDATA[SELECT * FROM PAGES WHERE Pages.fkbookId= :id]]>
  </sql-query>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to