IRowMapper<TResult> & Enums

Topics: Data Access Application Block
May 12, 2010 at 5:10 AM
Edited May 12, 2010 at 5:27 AM

Has anyone ran into an issue where IRowMapper<TResult> is having problems mapping objects with enums?
I am receiving the following exception when trying:

EnumConverter cannot convert from System.Int16

The type in the database is smallint and I am trying to map to an enum which inherits from System.Int16.

Thanks,

Michael

May 12, 2010 at 5:39 AM

Do you mean to say in cases where you don't pass an instance of IRowMapper?  I just tried it and confirmed that it is unable to map to enumerations.  The solution of course is to create your own implementation of an IRowMapper. 

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 12, 2010 at 6:09 AM

Yes... this is what I meant.
It seems weird to me that the default implementation would not take into account enums.

Michael

May 12, 2010 at 6:21 AM

I'm not sure if it's a bug, better log it in the Issue Tracker.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com

May 12, 2010 at 6:37 AM

Will do... thanks for the QUICK help!!

Michael