This project has moved and is read-only. For the latest updates, please go here.

enum variable as column

Oct 30, 2013 at 11:36 AM
public enum ETRADECMD
{
    [Description("BUY")]
    BUY,
    [Description("SELL")]
    SELL
};
ETRADECMD type;


WHERE type = 'SELL'
WHERE type = 1

both give exception.
Cannot apply binary operator '=' on types 'ETRADECMD' and 'String'
Cannot apply binary operator '=' on types 'ETRADECMD' and 'Int32'

How to use enumarations?
Oct 30, 2013 at 10:03 PM
The easiest way is calling the ToString() method:
select * from myTable t where t.ETRADECMD.ToString() = 'BUY'
A better way would be to register a ColumnBinding that returns the string value instead of the enum value. See the Help, section Extensibility | Custom Tables.

Does this help?
Oct 31, 2013 at 8:42 AM
select * from myTable t where t.ETRADECMD.ToString() = 'BUY'
this gives error or i did it wrong.

i dont want to implement second solution.

Could enumarations support at least int value?