This question is locked. New answers and comments are not allowed.
I have latitude and longtitude and coordinate in a SQL DB stored as numeric(9,6), numeric(9,6),geography.
OpenAccess mapped this as Double,double,SqlGeography.
and I added web service(web api) to tfr.
I tried to find all points within a distance around my loc as you described link
extended TFRsControler.partial.cs
public virtual IQueryable<
TFR
> GetByCoordinateRad(double _lat,double _lon, int _radius)
{
SqlGeography myLoc = SqlGeography.Point(_lat, _lon, 4326);
double distanceMeter=_radius*1000.0;
IQueryable<
TFR
> entity = repository.GetAll().Where(s => (double)s.Coordinate.STDistance(myLoc) < distanceMeter);
if (entity == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return entity;
}
but give this error:
System.ArgumentException was unhandled by user code
HResult=-2147024809
Message='Microsoft.SqlServer.Types.SqlGeography' türünde tanımlanan 'System.Data.SqlTypes.SqlDouble STDistance(Microsoft.SqlServer.Types.SqlGeography)' yöntemi 'Microsoft.SqlServer.Types.SqlGeography' türündeki örnekle çağrılamaz
Source=System.Core
StackTrace:
konum: System.Linq.Expressions.Expression.ValidateCallInstanceType(Type instanceType, MethodInfo method)
konum: System.Linq.Expressions.Expression.ValidateStaticOrInstanceMethod(Expression instance, MethodInfo method)
konum: System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
konum: System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression[] arguments)
konum: SocialTraffic.WebApiService.TFRsController.GetByCoordinateRad(Double _lat, Double _lon, Int32 _radius) *****.WebApiService\TFRsController.partial.cs içinde: satır 34
konum: lambda_method(Closure , Object , Object[] )
konum: System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
konum: System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
konum: System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()
konum: System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
InnerException: