Equals Expression ignores custom methods.

Description

I have a case where I am running a simple expression against an IQueryable<T> (NHQueryable<T>) instance. I am using the 'Equals' expression with a custom method but said method is ignored come execution time. Here is what code I am using.

Expression compare = Expression.Equal(propNode, compNode, false, ContainsMethod);

This is my ContainsMethod:
private static bool StringContains(string haystack, string needle)
{
return haystack.ToLower().Contains(needle.ToLower());
}

If I were to use the expression
(x => x == "a") in conjunction with the following list of strings;

"Batman", "Superman", "WonderWoman"

Then each of the items should be returned, instead none of them are. If I set breakpoints on my custom method 'StringContains' then nothing happens, proving that it is ignored. Instead the expression acts like a normal 'Expression.Equal'

I know that this is a specific problem with NHQueryable<T> because if I use the exact same approach on say a 'List<string>.AsQueryable()' then I get the expected result.

If anyone can provide me with some information on how to write a test case (as well as run them) to include in the NHibernate source code, I would be more than happy to do so.

Environment

None

Assignee

Unassigned

Reporter

Andrew A Ritz

Labels

None

Components

Affects versions

Priority

Blocker
Configure