Some databases now have built in support so that what you are looking for
can be done completely DB server side....

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Marcelo Grossi
Sent: Friday, April 13, 2012 2:56 PM
To: nhusers
Subject: [nhusers] Mapping a scalar function?

Hi all,

I need a, very common nowadays, distance from locations filter. I have a
resource that has an address that itself have lat and long properties. I
also have a base location that I want to compare against all the resources
locations and filter out those who are at most "radius" meters distant from
my base location.

I would like to use the linq notation to be consistent throughout my
project. I found out that you can re-write the SqlDialect to support a new
function. My question is: is this the only way or is there some special
mapping that I can make in order to map a function in my object to a
database filter call. Like so:

from r in Resource
where r.DistanceFromLocation(constant_input_location) <=
constant_input_radius select r...

This way in my entity mapping class (I'm using the Map By Code approach in
NH 3.2) I would simply map my function as if it were a property. Like so:

Property(...);
CustomFunction(x => x.DistanceFromLocation, m => m...);

I'm really new to both NHibernate and Mapping By Code so please bear with my
ignorance. Am I dreaming here or is this actually possible?

Sorry in advance if this is too far-fetched. The thing is that NH does
everything I need and more so why not this? :-)

Thanks in advance is anyone has any idea on the subject.

--

--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to