Hi there,
The issue AR-ISSUE-239 was just created by Courtney Shrock (clshrock).
Key: AR-ISSUE-239
Summary: ScalarQuery.Generic.Execute() throws exception if T is an int
(build 1035)
Type: Bug
Importance: High
Description:
Using the example modified from
http://www.castleproject.org/activerecord/documentation/trunk/usersguide/hql.html,
this code section will fail with an invalid cast exception:
public int HighestRating()
{
ScalarQuery<int> q = new ScalarQuery<int>(typeof(Post), @"
select max(p.Rating)
from Post p
where p.Blog = ?
", this);
return q.Execute();
}
System.InvalidCastException: Specified cast is not valid.
at Castle.ActiveRecord.Queries.ScalarQuery`1.Execute() in
c:\ccnet\CastleWorkDir\WorkingDirectory\ActiveRecord\Castle.ActiveRecord\Framework\Queries\ScalarQuery.Generic.cs:line
98
line 98 reads:
return result == null ? default(T) : (T)result;
Obviously, if the result is a value type, the comparison with null will throw
the exception. Why not just:
return ActiveRecordMediator.ExecuteQuery(this);
For more, see
http://support.castleproject.org/projects/AR/issues/view/AR-ISSUE-239
--
donjon
by Castle Stronghold
http://www.castle-donjon.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---