I've been thinking about this idea for a while now, and I thought I'd
write an email to see what you (other AR developers) thought about it.
Now that ActiveRecord officially has LINQ support, I've been thinking
about ways to use user-defined functions (UDFs) with it. It would be
pretty useful (to me, anyway) to be able to define a delegate or
abstract method in my class (or in another static class) that is
mapped to a UDF, which could then be called via LINQ (when AR or NH
translates the LINQ expression tree to SQL).
For example, I'm working on an application right now where I'm using
SQL Server and some user-defined CLR functions. It would be pretty
helpful if I could create a static class with something like this:
public static class MyClass
{
[UserDefinedFunction("fnCombinedStringLengths")]
public static int CombinedStringLengths(string s1, string s2)
{
return s1.Length + s2.Length;
}
}
Then I could call it when using LINQ on a model class:
SelectedClasses = Foo.Where(f => CombinedStringLengths(f.FirstName,
f.LastName) < 5)
And AR/NH would be able to use the function "fnCombinedStringLengths"
when translating the LINQ into a SQL string, so that the function is
evaluated in the database. If the database dialect doesn't support
user defined functions (or the function isn't defined in the database)
the static function will just be evaluated on the host, as it
currently would be.
What do you all think of this idea? I'll be glad to help out writing
some of the code to implement it, I'm just not sure where it would
need to go (in NH or AR)...
Cheers,
Jack
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Development List" 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/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---