Distance and IsWithinDistance

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Posts: 5
Joined: Fri 24 Feb 2017 06:08

Distance and IsWithinDistance

Post by NSY738 » Tue 11 May 2021 06:32

I have a problem.
I need to use the distance and IsWithinDistance functions in entity framework core 5.

But when I write this,
var result = dbContext.Addresses.Where( u => u.Geometry.IsWithinDistance(geometry, km)).Select(u => u.Id).ToList();

I get an error.
The LINQ expression 'DbSet<Address>()
.Where(o => o.Geometry.IsWithinDistance(
geom: __geometry_0,
distance: __p_1))' could not be translated. Additional information: Translation of method 'NetTopologySuite.Geometries.Geometry.IsWithinDistance' failed. If this method can be mapped to your custom function, see https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Can you give me some advice on how to solve this problem.

Thank you

Site Admin
Posts: 9301
Joined: Thu 14 Aug 2008 12:44

Re: Distance and IsWithinDistance

Post by Shalex » Thu 13 May 2021 13:44

Geometry.IsWithinDistance() is currently not supported in our EF Core implementation. We will investigate the question and notify you about the result.

Post Reply