StrataFrame Forum

Enums and SmallInt

http://forum.strataframe.net/Topic13428.aspx

By Bill Cunnien - 1/14/2008

I was having trouble getting an enum type to work properly on one of my business objects.  The DB type was smallint.  I kept getting 'specified cast is invalid'.  Of course, I kept thinking I was doing something wrong.  Then, on a whim, I changed the DB type from smallint (int16) to int (int32) and the enum type now works without errors.

Can someone please confirm that a smallint data type will not work with enumerations in StrataFrame? 

Thanks,
Bill

By Trent L. Taylor - 1/14/2008

Can someone please confirm that a smallint data type will not work with enumerations in StrataFrame? 

This is not StrataFrame...this is .NET.  You can define an enum several different ways, but if you do not implicitly define the integer type, then it assumes Int32.  So yes, it is generally best to use an Int32 for Enums:

Public Enum MyEnum As Integer - Implied if left off

By Bill Cunnien - 1/14/2008

Excellent!  Thank you!!