Compiling aspx forms

27. September 2012 13:02 by martijn in

Build succeeded run...fail. It annoys me that I use a TYPE SAFE language like C#, use ASP.NET with ItemType (strongly typed stuff) and still get runtime errors. So I have to click through every page when I refactor? 

 
Luckily compiling the views can be done by adding a afterbuild or using a postbuild event. Here what you paste in your afterbuild event to get the aspx compiling :
 
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v /-p "$(SolutionDir)$(ProjectName)"

Adding support for spatial types to Windows Server 2008 R2 x64

25. September 2012 20:10 by admin in
Recently I deployed a site that internally used the new spatial CLR type DbGeography. When I tried to run I got the folowwing error :

Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found

This basically means that a dll is missing on the box. Since it is non-trivial to find this dll I'll blog about it. You have to install the SQLCltTypes package. If you install the wrong version of the package you might get a problem with SqlServerSpatial not being installed. The version that worken for me on Windows Server 2008 R2 x64 was here (below the x64 folder)


Distances with DbGeography and DbGeometry

23. September 2012 08:21 by admin in
In a recent project we had to do some spatial search (finding nearest shops). With the new EntityFramework 5.0 in asp.net 4.5 this is finally possible. To get the nearest products (in a search) you write something like:


Now there can be some confusion about which type to use for location. There are two types to describe the 'location' of an object:

From MSDN:
DbGeography : Represents data in a geodetic (round earth) coordinate system.
DbGeometry : Provides a base class for objects that define geometric shapes. 

Now here is a big difference. The first class being a point on earth and the second one a point (or shape). DbGeometry does not include anything about dimensions. This is clear when calculating the distance. When calculating distance for DbGeography the result is given in meters. For DbGeometry the result is still dimension less. A bit of code can say more than a thousand words...


So for real-world objects use DbGeography as location!