Nhibernate 'Not all named parameters have been set' when using spatial query -


this query

var selectdinnerbydistance = string.format(             @"select                  u.profileimageurl profileimageurl,                  d.starter starter,                 d.main main,                 d.dessert dessert,                 d.dry drydinner,                 d.[date] eventdate,                 l.geoloc.stdistance(geography::stgeomfromtext('point({0} {1})', 4326)) distance                 dbo.locations l                 join dinners d on d.locationid = l.id                 join users u on u.id = d.userid                 order distance asc                 offset {2} rows                 fetch next {3} rows only"             , lat, lng, skip, take); var output = _session      .createsqlquery(selectdinnerbydistance)      .setresulttransformer(transformers.aliastobean<dinnerlistitemdto>())      .list<dinnerlistitemdto>(); 

and exception i'm getting is

not named parameters have been set: [':stgeomfromtext'] 

the query works fine in management studio. there way should using straight sql queries avoid error?

thanks

as stated in comments above. solution rewrite query in different way replaced "geography::stgeomfromtext"

l.geoloc.stdistance(@dist.stbuffer(0.2).stastext()) distance 

and placed following @ top of query

declare @dist geography = 'point({0} {1})' 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -