Check
http://fabiomaulo.blogspot.com/2010/07/nhibernate-linq-provider-extension.html
.
You can extend the Linq Provider to translate the class to
String.Compare in a HqlNode.
Here is a similar class for Int32.Compare:
public class Int32LinqGenerator : BaseHqlGeneratorForMethod
{
public Int32LinqGenerator()
{
SupportedMethods = new[]
{ ReflectionHelper.GetMethodDefinition<Int32>(x =>
x.CompareTo(Int32.MinValue)) };
}
public override NHibernate.Hql.Ast.HqlTreeNode
BuildHql(System.Reflection.MethodInfo method,
System.Linq.Expressions.Expression targetObject,
System.Collections.ObjectModel.ReadOnlyCollection<System.Linq.Expressions.Expression>
arguments,
NHibernate.Hql.Ast.HqlTreeBuilder treeBuilder,
NHibernate.Linq.Visitors.IHqlExpressionVisitor visitor)
{
HqlExpression nodeTarget =
visitor.Visit(targetObject).AsExpression();
return treeBuilder.Subtract(
nodeTarget,
visitor.Visit(arguments[0]).AsExpression()
);
}
}
Andrei