I correct myself, the complete error is:

[InvalidCastException: Object must implement IConvertible.]
   System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider) +10246653
   System.Data.SqlClient.SqlParameter.CoerceValue(Object value,
MetaType destinationType) +1367

[InvalidCastException: Failed to convert parameter value from a
RuntimeTye to a Int32.]
   System.Data.SqlClient.SqlParameter.CoerceValue(Object value,
MetaType destinationType) +6280742
   System.Data.SqlClient.SqlParameter.GetCoercedValue() +63
   System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean
isCommandProc) +296
   System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser,
SqlParameterCollection parameters) +261
   System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior
behavior, String commandText, SqlParameterCollection parameters,
_SqlRPC& rpc) +295
 
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +6282737
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +424
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +28
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) +211
 
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +19
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
+21
   NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
+703
   NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean
autoDiscoverTypes, Boolean callable, RowSelection selection,
ISessionImplementor session) +544
   NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies) +261
 
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies) +105
   NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters) +201


On Apr 14, 5:35 pm, Marc Climent <[email protected]> wrote:
> Hi all.
>
> I wasn't able to find information on a problem I'm facing. The
> following Criteria query works perfectly for me:
>
> var query = session.CreateCriteria(typeof (Content));
>
> query.Add(Property.ForName("Parent").Eq(parent));
> query.Add(Property.ForName("class").Eq(typeof(ContentSubclass));
>
> var list = query.List<Content>();
>
> Where content has many subclasses (with joined-subclass mapping) and I
> want to get only the Children of a specified type.
>
> If I use HQL instead of Criteria, I think it should read:
>
> var queryString =  "from Content as c where c.Parent=:parent and
> c.class=:clazz";
>
> var query = session.CreateQuery(queryString);
>
> query.SetParameter("parent", parent);
> query.SetParameter("clazz", typeof(ContentSubclass));
>
> var list = query.List<Content>();
>
> In this case, it throws a SQL error, because the class is passed as a
> String and tries to be converted to an Int32 when NHibernate is
> creating the parametrized query.
>
> I can work with Criteria, but this behavior seemed strange to me, did
> I miss something?
>
> Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to