LINQ to NHIBERNATE – Did not implement method COS

In Linq to NHibernate, I am trying to return business users within a certain distance. This is what I have so far:

var query = from b in ActiveRecordLinq.AsQueryable()
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 Linq to NHibernate does not support the C#Math class, so it gives me the following error:

Method Cos is not implemented

How can I bypass this?

Thank you!
Justin

You can do three things:

> Implement it and submit a patch to NHibernate so that everyone can use your implementation
>Create a failed unit test, isolate the problem and submit it to NHibernate Jira and wait for others to implement it.
> Don’t use Linq, but use ordinary old sql or mixed hql for this query.

When you choose option 1, you will make some people happy.

In Linq to NHibernate, I am trying to return business users within a certain distance. This is what I have so far:

var query = from b in ActiveRecordLinq.AsQueryable()
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 Linq to NHibernate does not support the C#Math class, so it gives me the following error:

Method Co s not implemented

How can I bypass this?

Thank you!
Justin

You can do three things:

>implement it and submit a patch to NHibernate so that every Individuals can use your implementation
>Create a failed unit test, isolate the problem and submit it to NHibernate Jira and wait for others to implement it.
>Don’t use Linq, but use plain old sql or Mix hql for this query.

When you choose option 1, you will make some people happy.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4483 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.