Hi All,
I'm currently trying to add a "more like this" function to my website,
this requires that I pull records ordered by NewID.. If I was using
SQL I'd do this..
SELECT TOP 5 *
FROM video
ORDER BY NEWID()
But it seems that NewID is not a part of the MSSql2005 dialect? So to
add it I' have the following dialect extension (I'm using the Castle
stack by the way)
public class MSSql2005Extension : MsSql2005Dialect
{
public MSSql2005Extension()
{
RegisterFunction("newid", new NoArgSQLFunction("NEWID",
NHibernateUtil.Int32));
// RegisterFunction("newid", new StandardSQLFunction("NEWID()",
NHibernateUtil.Int32));
}
}
And I'm registering like so..
<add key="dialect" value="Core.MSSql2005Extension, NooStar" />
Sadly when I call this..
DetachedCriteria criteria = DetachedCriteria.For<Video>()
.AddOrder(Order.Desc("NewId()"))
.SetMaxResults(maxResults);
I get..
could not resolve property: NewId() of: NooStar.Core.Video
Can any one point me in the direction of what I'm doing wrong? Any
help would be a huge help.
Thanks in advance,
Richard Adams
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---