Skip to content Skip to sidebar Skip to footer

How To Map An NHibernate Entity To A Query

I've seen a number of examples of this, and as far as I can tell my HBM file follows the same pattern, but it's not working. First, the file:

Solution 1:

One way how to achieve this, would be to move the mapping from a query into the subselect:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping default-cascade="save-update" xmlns="urn:nhibernate-mapping-2.2">
  <class name="ThinAir" mutable="false" lazy="true" >

  <subselect>
    <![CDATA[
    SELECT DISTINCT JobID,
    userLogin,
    DateProcessed,
    useremail
    FROM         dbo.someothertable
    ]]>
  </subselect>

  ... // rest of the mapping

Post a Comment for "How To Map An NHibernate Entity To A Query"