-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlServer Spatial: Cannot call methods on varbinary #14595
Comments
|
This is a limitation caused by using System.Data.SqlClient without Microsoft.SqlServer.Types--we can't specify the type of the SqlParameter. WorkaroundRewrite the expression to begin with a column (or a dataContext.Addresses.Where(x => x.Location.Within(searchGeometry)) |
Notes from triage:
|
I had the same issue, its ok |
Next steps: @bricelam file an issue on corefx. |
@bricelam could you please provide an example of rewriting the expression to use new geometry? We are experiencing a performance issue with
works much slower then
So, rewriting an expression to begin with a column is not an option in this case. We tried rewriting the expression to start with a |
@snakenstein When you say, "works much slower than" can you provide some details on:
This will help us understand the impact here. |
@ajcvickers Sorry for the delay. In short, answers to your questions are:
We have caught a query that EF Core was issuing to the database in SQL Server Profiler and started investigating the problem in SQL Server Management Studio.
We want to get count of resumes from workers that has address located within 100 km from a given point (plus some conditions on resume and customer). In our test database this query executes 7-8 seconds.
When we changed the query to call STDistance on @__location_0 variable and pass [wp.Worker.Customer.Address].[Location] column as an argument, we got 2-3 seconds execution time on the same database.
The difference in execution plans of this queries is in this part: We are running MS SQL Server 2016 SP2 (13.0.5081.1) |
This should be as trivial as updating this method to leverage the feature added to SqlClient. |
Issue
SqlException when testing if a polygon contains a point.
I have a table in the database called Address with a Location column (of GEOGRAPHY data type). The goal is (ultimately) for a user to draw a boundary polygon on a map and the database query will return all records where the Location is within the polygon. However I'm seeing the following exception when executing the code.
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
Program.cs
Address.cs
SpatialDataContext.cs
Source solution also available at: https://gitlab.com/stuartwhiteford/efcorespatialdata
The SQL generated is as follows:
but the following DOES work:
Further technical details
EF Core version: 2.2.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer 2.2.1
Using: Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite 2.2.1
Operating system: Windows 10 Pro - Version 1803 - OS Build 17134.523
IDE: (e.g. Visual Studio 2017 15.9.6)
The text was updated successfully, but these errors were encountered: