Reputation: 513
I am using EFv5 which now has the geography data type. So i have an entity called Place and it has a property called geoLocation that is of type geography. VS 2012 has automatically created the code for this entity and the property type for this geography type has been declared as System.Data.Spatial.DbGeography. So everything is working fine.
But when i add a domain service class and tick to include my place entity the solution stops compiling since the domainservice.metaData.cs file does not seem to be able to create the property for the geography type. And i get an "Entity 'SilverlightApplication1.Web.Place' has a property 'GeoLocation' with an unsupported type" error message.
So how do i include this geography data type in my domain service class?
I have tried to manually add the property to the created metadata file but i still get the same error message.
Upvotes: 3
Views: 472
Reputation: 39
I've had success using the DbGeography type in my domain classes within an MVC project.
I define my domain class as follows.
using System.Data.Spatial;
namespace MyApp.DomainClasses
{
public class Address
{
public int Id { get; set; }
public string StreetAddress { get; set; }
public string InternalMailCode { get; set; }
public string City { get; set; }
public string Country { get; set; }
public string PostalCode { get; set; }
public string StateProvince { get; set; }
public DbGeography Location { get; set; }
}
}
Then I can query with something like this.
var myLocation = DbGeography.FromText(gpsLocation);
var addresses= (from a in context.Addresses
orderby a.Location.Distance(myLocation)
select a).Take(10);
Upvotes: 3