Entity Framework Spatial Aggregate Functions
Sql Server has useful spatial aggregation functions which are described here .
Just wondering if they are available through the Entity Framework API? For example, can I use an envelope aggregation query in Entity Framework LINQ?
Entity Framework 6 has a class that calls SqlSpatialFunctions that provided some of the spatial functionality of SQL Server, but I couldn't find the EnvelopeAggregate function.
Does Entity Framework provide any equivalent API or do I need a raw TSQL query>
+3
source to share
1 answer
I haven't been able to find a LINQ-based solution, but here's an example of using a raw SQL query in Entity Framework 6 for reference:
// Need to use SQL since EF doesn't support spatial aggregates
var querySql = @"SELECT
Geometry::UnionAggregate([SpatialBounds])
FROM [dbo].[LandgateLocation]
WHERE [Distict] = (@p0)";
var polygon = await dbContext.Database.SqlQuery<DbGeometry>(querySql, request.District).SingleAsync();
0
source to share