These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to use table-valued UDF from NHibernate?
PostPosted: Thu May 06, 2010 12:54 am 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:38 am
Posts: 28
Hey guys,

I'm trying to use a table-valued user-defined function (SQL Server) from NHibernate. However, I just can't seem to get the registration and/or the query right. Here is what I have...

Code:
CREATE FUNCTION GetIDs ()
RETURNS @IDs TABLE
(
   ID int,
   Level int
)
...


So it's a function that does not require any parameters, but that returns two int columns.

Next, I'm adding the function to my session factory (I know other people recommend to create your own dialect but I find this here easier):

Code:
sessionFactory.Dialect.Functions.Add("dbo.getids", new StandardSQLFunction("GetIDs"));


Then I try to create a query.

Code:
IQuery query = m_Session.CreateQuery("from dbo.GetIDs() as ids");


I get exceptions when I try to create the query. Obviously, I have tried various query variations (with and without the dbo., etc), and I get varying error messages, such as:

in expected: ( [from GetIDs() as ids]
undefined alias or unknown mapping: dbo [from dbo.GetIDs() as ids]


I believe the problem is with adding the function. The main problem is that I have not found a single example that registers a table-valued function, only scalars.
Plus, the examples seem to be from NH 1.2.

Does anybody have a working NH 2.x example of how to use a table-valued UDF?

Thanks, Christoph


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.