Description
Greg Borota created an issue — 4th March 2012, 7:12:33:
With following line of code inside
NHibernate.Impl.ExpressionProcessor.ConvertType
if (type.IsEnum)
return Enum.ToObject(type, value);
The assumption is made that a column of Enum type is always mapped to string column inside db. Which doesn't have to be the case...I am mapping an enum to an int column, and code break because of this faulty assumption.
Richard Brown added a comment — 4th March 2012, 17:09:37:
Hi Greg,
The default for NH is to map enums to int columns. I've tried this in the NH tests, and it appears to work correctly.
Can you provide a test case demonstrating the issue?
Cheers,
Richard
Greg Borota added a comment — 5th March 2012, 2:40:28:
Hi Richard,
I looked more into the issue and it happens only in a very particular case where I cast the enum to string in the select list.
I found a workaorund so I am no longer borthered that much by it. If I declare an alias in the QueryOver<>(() => alias) then thing work as expected.
I am trying to upload a test case showing the problem as well as the workaround, but it seems like the site won't upload my file. I'll try zipping it with 7z, see if that works.Thanks,
Greg
Greg Borota added a comment — 5th March 2012, 2:43:23:
Unit test exemplifying both the problem and solution