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

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    9 posts
    Member since:
    Sep 2012

    Posted 04 Mar 2014 Link to this post

    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();

  2. Ady
    Admin
    Ady avatar
    588 posts

    Posted 06 Mar 2014 Link to this post

    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.
  3. DevCraft banner
Back to Top