If you are passing parameters into your TVF (and into CONTAINSTABLE)
then it will need to be a custom SQL query. If you aren't passing any
parameters in then you have the option of using a view instead of a
TVF.
Out of interest, why do think that a parameter-less TVF won't work for
joins and associations? I would think you could just put it in the
table attribute of your <class> mapping.
If it's any help, here's one example of how we use a TVF to load up
some entities:
<class name="Beacon.Business.ContactHistory.ContactHistoryEvent,
Beacon.Business"
table="ContactHistoryEvent"
lazy="false"
mutable="false">
<!-- property mappings here -->
</class>
<resultset name="DefaultContactHistoryMapping">
<return
class="Beacon.Business.ContactHistory.ContactHistoryEvent,Beacon.Business">
<!-- return-property translations here -->
</return>
</resultset>
<sql-query name="ContactHistoryEventOutput" resultset-
ref="DefaultContactHistoryMapping">
<![CDATA[ SELECT * FROM ContactHistoryEventOutput ( ?, DEFAULT,
DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT ) ]]>
</sql-query>
In a couple of places, we've also used the output of TVFs as the
source for collections from other entities.
One word of warning ... NHib places great emphasis on the identity of
an entity. You need to make sure the output of your TVF respects
this, if there is any possibility of the TvF being called twice within
the same session.
Cheers,
John
On Jun 23, 1:57 pm, JamesSpibey <[email protected]> wrote:
> Hi,
>
> We need to use the Sql Server CONTAINSTABLE() function from NHibernate
> and the way we have done this in the past is to wrap it in a Table
> Value Function (TVF) and then join on this.
>
> Is there a way to use TVFs from NHibernate to map to a type? We will
> need to join on the TVF and create associations etc so I don't think a
> custom SQL query will do it
>
> Thanks
>
> James
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---