cancel
Showing results for 
Search instead for 
Did you mean: 

Isn't it possible to assign Tinyint column to .Net byte?

Former Member
5,036

This question is just out of curiosity, fyi, for this application it makes no difference if I used short or byte, but I wanted to ask anyway.

When mapping a tinyint column to a byte property of an entity, I get this exception: Dialect does not support DbType.Byte. I'm using SA12.0.1 and NHibernate 3.1 with Glenn Paulley's dialect. I haven't upgraded to NH3.2 yet since FluentNH didn't catch up yet.

If I use a property of type short, it's ok, no complaints. In the documentation for tinyint, it's also stated that "Also, to send a TINYINT value to a database from an application written in C, the type of the C variable should be integer."

Since both SA tinyint and .Net byte are unsigned types ranging 0-255, why would not the former be assigned to the latter?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

I think the problem is simply that the mapping of BYTE to TINYINT isn't present in my dialect - an oversight on my part.

If you want that specific mapping, you can add the line

        RegisterColumnType(DbType.Byte, "TINYINT");

to the RegisterNumericTypeMappings()routine yourself, and then recompile the NHibernate DLL with Visual Studio.

I will submit this to the NHibernate forum as a bug, so that it can be corrected in a subsequent NHibernate distribution.

Former Member

Thank you for taking the time. As a note to future readers, I managed to get it working without recompiling NH by adding the line you mentioned to SybaseSQLAnywhere12Dialect class constructor.

Answers (0)