Hi,
I have been working on a project which is to use the .Net 4.5 DbGeography data type but I am having problems working with the data type with DNN7's implementation of PetaPoco. It would seem that it does not support it.
I get an error "No mapping exists from object type System.Data.Spatial.DbGeography to a known managed provider native type"
I have found an article about how to allow spatial data types by editing PetaPoco.cs but this is in regards to the original library. http://john.katsiotis.com/blog/petapoco-and-spatial-data-types
How might I get spatial data types to work with DNN7?
This is my code by the way. It errors on rep.Insert()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Web;
using System.Net.Http;
using System.Web.Http;
using System.Data.Spatial;
using DotNetNuke.Web.Api;
using DotNetNuke.Data;
namespace DotNetNuke.Modules.GeoLocations
{
public class LocationController: DnnApiController
{
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage HelloWorld()
{
return Request.CreateResponse(HttpStatusCode.OK, "Hello World!");
}
[AllowAnonymous]
[HttpPost]
[ValidateAntiForgeryToken]
public HttpResponseMessage addLocation(CP_Location submitted)
{
//submitted.GeoCode = DbGeography.PointFromText(string.Format("POINT({0} {1})", submitted.Long, submitted.Lat), 4326);
createLocation(submitted);
return Request.CreateResponse(HttpStatusCode.OK, "Success");
}
//------------------------------CRUD------------------------------//
public void createLocation(CP_Location location)
{
using (IDataContext ctx = DataContext.Instance())
{
var rep = ctx.GetRepository<
CP_Location
>();
rep.Insert(location);
}
}
}
}