NHibernate CreateSQLQuery data conversion from bit to boolean error

Posted by RemotecUk on Stack Overflow See other posts from Stack Overflow or by RemotecUk
Published on 2010-05-06T16:26:28Z Indexed on 2010/05/06 18:18 UTC
Read the original article Hit count: 489

Filed under:
|
|

Hi,

Im being a bit lazy in NHibernate and using Session.CreateSqlQuery(...) instead of doing the whole thing with Lambda's. Anyway what struct me is that there seems to be a problem converting some of the types returned from (in this case the MySQL) DB into native .Net tyes.

The query in question looks like this....

     IList<Client> allocatableClients =
                    Session.CreateSQLQuery(
                      "select clients.id as Id, clients.name as Name, clients.customercode as CustomerCode, clients.superclient as SuperClient, clients.clienttypeid as ClientType " +
...
...
.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(Client))).List<Client>();

The type in the database of SuperClient is a bit(1) and in the Client object the type is a bool.

The error received is:

System.ArgumentException: Object of type 'System.UInt64' cannot be converted to type 'System.Boolean'.

It seems strange that this conversion cannot be completed.

Would be greatful for any ideas.

Thanks.

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about c#