This is a migrated thread and some comments may be shown as answers.

Spatial types performance

1 Answer 62 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Валерий
Top achievements
Rank 1
Валерий asked on 14 Jul 2015, 04:01 PM

I want to draw all geometry from database that instersects with specified rectangle with this code.

But, is selects 1) Parcels that intersect in one query 2) Geometry of each parcel in other queries

1) SELECT a.[Id] AS COL1, a.[CertificationDocId] AS COL2, a.[CertificationDocId] AS COL3, a.[Number] AS COL4 FROM [Parcels] a WHERE a.[Number] LIKE @p0 + '%' ESCAPE '\' AND a.[Geometry].STIntersects(@p1) = 1 ORDER BY COL1 

2) SELECT [Geometry] AS COL1 FROM [Parcels] WHERE [Id] = @p0

 

Can i use a single query somehow? 

 

using (var quartersDb = new ProjectsByRegionsContext())
{
var parcels = quartersDb.Parcels
.Where(p => p.Number.StartsWith(regionCode) && p.Geometry.STIsValid().ToString() == "1" && p.Geometry.STIntersects(sqlGeometry).Equals(1))
.ToList();
foreach (var parcel in parcels)
{
if (usedCadNumbers.Contains(parcel.Number))
continue;
usedCadNumbers.Add(parcel.Number);
var drawedGeometry = CommandHelper.DrawGeometry(parcel.Geometry.ToNtsGeometry());
BlockHelper.CreateBlock(parcel.Number, drawedGeometry, parcel.GetAttributes());
}
}

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 16 Jul 2015, 01:47 PM
Hi Valery,

please have a look at http://docs.telerik.com/data-access/developers-guide/database-specifics/microsoft-sql-server/data-access-tasks-mssql-spatial-data .
There it is described how to use spatial types with DataAccess. SqlGeometry and SqlGeography behave in similar ways, and you might be able to deduce the solution to your issue.
One additional note: It might be needed / or just easier to use a piece of SQL in the LINQ directly. We support that too with 'SQL islands' that you can use to express your needs. Please see this article http://www.telerik.com/support/kb/data-access/details/using-full-text-search-features-with-linq-queries for more information. It can come handy when dealing with the results from the spatial methods.

Please note also: Telerik Data Access supports only version 10.0 of the Microsoft.SqlServer.Types assembly. We do not test with the newer versions, but they might work fine with a bit of binding redirection.


Regards,
Thomas
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Data Access Free Edition
Asked by
Валерий
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or