Csla.Test.CslaQueryProvider.TestQueryProviderAverageWithCriteria failure.

Csla.Test.CslaQueryProvider.TestQueryProviderAverageWithCriteria failure.

Old forum URL: forums.lhotka.net/forums/t/4942.aspx


sentientpc posted on Thursday, June 05, 2008

For some reason in cslatest-3.5.0-080222 and cslatest-3.5.0-080403 I receive the following nunit failure for test Csla.Test.CslaQueryProvider.TestQueryProviderAverageWithCriteria:
Tests run: 245, Failures: 1, Not run: 0, Time: 20.406 seconds

Failures:
1) Csla.Test.CslaQueryProvider.CslaQueryProviderTests.TestQueryProviderAverageWithCriteria : System.ArgumentException : Object of type 'System.Func`2[Csla.Test.CslaQueryProvider.RandomThing,System.Int32]' cannot be converted to type 'System.Func`2[Csla.Test.CslaQueryProvider.RandomThing,System.Single]'.
   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Csla.Linq.CslaQueryProvider`2.Execute(Expression expression) in d:\Projects\csla\Csla\Linq\CslaQueryProvider.cs:line 272
   at Csla.Linq.CslaQueryProvider`2.Execute[TResult](Expression expression) in d:\Projects\csla\Csla\Linq\CslaQueryProvider.cs:line 205
   at System.Linq.Queryable.Average[TSource](IQueryable`1 source, Expression`1 selector)
   at Csla.Test.CslaQueryProvider.CslaQueryProviderTests.TestQueryProviderAverageWithCriteria() in d:\Projects\csla\Csla.Test\CslaQueryProvider\CslaQueryProviderTests.cs:line 201

This only occurs on my build server, which is Win 2003 x64, it works fine on my Vista x86 dev machine.  Has anyone else run into similar errors?  Any suggestions would be greatly appreciated.

Matthew Krzan,
(NT4 & 2k) MCP, MCSE
(NT4) MCP+I, MCSE+I
MCDBA (7.0, 2000), MCTS: SQL 2005
ACISS Systems, Inc.

AaronErickson replied on Friday, June 06, 2008

Thanks for posting this.  I found a corner case in the MethodsEquivalent code that is supposed to map the expression tree passed in through the test to the correct matching method.  Your case was able to map, probably by accident, a lambda method that was expecting an int32 into a call that has as its parameter a lambda method that expects an int64.

I have added code in the MethodsEquivalent at the head of Linq\CslaQueryProvider.cs that solves the issue.  A fix for VB should be forthcoming as soon as I get back from TechEd (need to catch a flight soon...)

Copyright (c) Marimer LLC