This is a migrated thread and some comments may be shown as answers.

Spatial query error: "The query does not accept parameters, but valid params were passed for query"

1 Answer 158 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan
Top achievements
Rank 2
Ryan asked on 04 Mar 2014, 06:21 AM
Hi. I'm trying to do a fairly simple linq statement using STIntersect on SQL Server 2012 geography types, but I keep getting errors that I don't understand.
I put this question in the Data Type forum because I suspect it might be something to do with Microsoft.SqlServer.Types ver 11

//Attempt 1: Won't compile - "cannot convert type SqlBoolean to bool"
var myList = (from s in db.Suburbs where s.geom.STIntersects(myGeomPoint) == System.Data.SqlTypes.SqlBoolean.True.Value select s.SuburbName).ToList();
 
//Attempt 2: OpenAccessException - "The query does not accept parameters, but valid params were passed for query excecution"
var myList = (from s in db.Suburbs where (bool)s.geom.STIntersects(myGeomPoint) select s.SuburbName).ToList();
 
//Attempt 3: InvalidOperationException - "No AdoTypeConverter has been registered for the clrType."
var myList = (from s in db.Suburbs where s.geom.STIntersects(myGeomPoint).ToString() == "True" select s.SuburbName).ToList();

1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 06 Mar 2014, 01:06 PM
Hi Ryan,

 I did create a sample application where I created a model from the database where I had a 'geography' column in the database. I was successfully able to execute a 'STIntersects'  LINQ query.
'context.Countries.Where(cr => cr.Location.STIntersects(point).Equals(1)).ToList();'
The above format should work. 
I am not aware how you have created the model (Model first or database first) but the CLR field should have the following converter value specified - OpenAccessRuntime.Data.MssqlGeographyConverter
You can open the rlinq file in the designer, open the 'Model Schema Explorer', select the geography column and specify the above value for the 'Converter' property.

Do get back in case you need further assistance.

Regards,
Ady
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Tags
Databases and Data Types
Asked by
Ryan
Top achievements
Rank 2
Answers by
Ady
Telerik team
Share this question
or