Background : I need to create a custom like extension method for linqtohiberante to do the below,
result.Where(p => p.MyIntColumn.IsLike('%100%') );
so that would output a custom sql as follows.
select * from orders where CONVERT(VARCHAR, MyIntColumn) LIKE '%100%'
And I'm trying to build the custom expression for that by extending the BaseHqlGeneratorForMethod as shown below.
public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
{
return treeBuilder.Like(treeBuilder.MethodCall("convert",
new[] { "stuck here", visitor.Visit(arguments[0]).AsExpression() }),
visitor.Visit(arguments[1]).AsExpression());
}
I need to be able to inject the VARCHAR as a expression to the parameter list of the MethodCall expression. See the text "stuck here" in the above code snippet. Any idea how can I do that.
Thanks in advance
Bumble