In Entity Framework I have a DBGeography object:
using System.Data.Entity.Spatial;
...
public DbGeography Location { get; set; }
As I haven't discovered a better way to send a POINT
object over JSON, I'm intending to send 'lat' and 'lng' string values from my Javascript code and use them on the server during the POST method:
public async Task<IHttpActionResult> PostI4Item(myEntity item)
{
var lat = (VALUE TO BE SOURCED);
var lng = (VALUE TO BE SOURCED);
string Point = String.Format("POINT({0} {1})", lat, lng);
item.Location = DbGeography.PointFromText(Point, 4326);
myEntity current = await InsertAsync(item);
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
The problem is I don't know how to retrieve values sent to POST that are not expected within the data model. item.Location
is accessible because it has been declared. But, even if I am sending extra key/value pairs in the body of 'lat' and 'lng', how can I discover those values in code? I can't use item.lat
and item.lng
as they are not declared, and I don't want extra DB columns for those values... I only want them accepted as input, but not saved.
Is there a method in the data model where I can declare a value (perhaps something read-only or internal) which is expected on the request and available for use within the POST method, but is not actually being saved to my database?