I get a Antlr.Runtime.NoViableAltException
thrown when trying to run the following query in NHibernate.
IQuery query = session.CreateQuery("from <table> where 1 in (select <column>.ST开发者_开发问答Intersects(geography::STGeomFromText('POINT(:longitude :latitude)', 4326)))");
I'm setting longitude and latitude in setQuery.
my assumption is the ::
in calling geography::STGeomFromText...
because it's thinking it's a query parameter. Is there a way to escape the :
?
This query works in my SQL Manager Studio.
Thanks!
Does NHIbernate support the STIntersects method ?
What you could do, is let NHibernate execute a (native) SQL query, like this:
ISQLQuery query = session.CreateSQLQuery ("your sql statement goes here");
query.AddEntity (typeof(TheEntityTypeThatYouWant));
var result = query.List<TheEntityTypeThatYouWant>();
See this post for some more info: Using SQL Server 2008 Geography types with nHibernate's CreateSQLQuery
Just to share what I ended up doing was taking the ADO connection out of the NHibernate session, performing a SqlCommand directly and manually built my Model objects from the results. It sucks, but it works. The connection still managed by NHibernate correctly.
精彩评论