Reputation: 8071
I generate the function
if (geofence != null)
{
geofenceParameter = new ObjectParameter("geofence", geofence);
}
else
{
geofenceParameter = new ObjectParameter("geofence", typeof(System.Data.Spatial.DbGeography));
}
base.ExecuteFunction<AssetData>("FindLastGeofenceEnterOrExit", assetIdParameter, geofenceParameter, startDateParameter, isEnterParameter);
on SQL server it looks like this:
CREATE PROCEDURE [dbo].[sp_FindLastGeofenceEnterOrExit]
@assetId bigint,
@geofence geography,
@startDate datetime,
@isEnter bit
AS
But when i try to call that function VS throws the exception:
Can't figure out does EF supports it or not. I use EF 6.0.0.0
Upvotes: 0
Views: 344
Reputation: 3373
EF6 definitely supports geography types in stored procedures (as did EF5). Although I've only worked database first, I pulled this (modified slightly and simplified) from the EDMX file. Hope it helps.
public virtual ObjectResult<MyClass> MyStoredProcedure(System.Data.Spatial.DbGeography location, MergeOption mergeOption)
{
var locationParameter = location != null ?
new ObjectParameter("location", location) :
new ObjectParameter("location", typeof(System.Data.Spatial.DbGeography));
// EDIT: Neglected to copy this part in during original post
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<MyClass>("MyStoredProcedure", mergeOption, locationParameter);
}
Upvotes: 1