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.
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
Activity
Show:
Andrew A Ritz
February 15, 2011 at 6:49 AM
OK, someone on StackOverflow was nice enough to help me get the unit tests up and running. Hopefully I can submit one soon.
Andrew A Ritz
February 15, 2011 at 6:48 AM
OK, someone on StackOverflow was nice enough to help me get the unit tests up and running. Hopefully I can submit one soon.
Andrew A Ritz
February 15, 2011 at 6:48 AM
OK, someone on StackOverflow was nice enough to help me get the unit tests up and running. Hopefully I can submit one soon.
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.