Sql Server has useful spatial aggregate functions which are described here .
Just wondering are they available through Entity Framework API? For instance can I use Envelope Aggregate in Entity Framework LINQ query?
There is a class in Entity Framework 6 which calls SqlSpatialFunctions that provided some SQL Server spatial functions but I couldn't find EnvelopeAggregate function.
Does Entity Framework provide any equivalent API or I need to use raw TSQL query>
I haven't been able to find a LINQ-based solution, but for reference here's an example using a raw SQL query in Entity Framework 6:
// 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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.