In Linq to NHibernate I'm trying to return businesses within a certain distance of a user. Here is what I have so far:
var query = from b in ActiveRecordLinq.AsQueryable<Business>()
where (3959 * Math.Acos(Math.Cos((Math.PI * coordinates.Latitude / 180)) * Math.Cos((Math.PI * b.Latitude / 180))
* Math.Cos((Math.PI * b.Longitude / 180) - (Math.PI * coordinates.Longitude / 180))
+ Math.Sin((Math.PI * coordinates.Latitude / 180)) * Math.Sin((Math.PI * b.Latitude / 180)))) <= radiusInMiles
orderby b.Name ascending
select b;
return query.ToList();
Unfortunately, it seems that the C# Math class isn't supported in Linq to NHibernate so it gives me the following error:
The method Cos is not implemented
How would I get around this?
Thanks! Justin