how to include a spatial index in c# EF

Stephen Cameron 0 Reputation points
2024-08-21T11:02:07.8466667+00:00
This query is not using the spatial index: (@__point_0 sys.geometry)SELECT TOP(1) [t].[Id], [t].[Bus_StopsId], [t].[Point]
FROM [TripRef_Stops] AS [t]
WHERE [t].[Point].STBuffer(5.0000000000000002E-05).STContains(@__point_0) = CAST(1 AS bit) - it is transformed from c# in EF
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
736 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,858 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Stephen Cameron 0 Reputation points
    2024-08-22T09:23:09.54+00:00

    Thanks - the EF Distance() worked. I don't use Geography for that matching - so all good. Obviously multiple operators like Buffer().Contains() obviously break the index process.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.