Some clarification to Solution 1 (please see my comment to it):
Please look at the declaration of this extension method:
http://msdn.microsoft.com/en-us/library/bb360891%28v=vs.110%29.aspx[
^].
For some data row and some column name, the method attempts to get the attribute value for this row. Even though this syntax itself is
strongly typed, there is no such thing as miracle: the
runtime type for the attribute may or may not be
assignment-compatible with the actual generic parameter type you use (
int
, in this case). If it is not compatible, type cast is failed, throws exception you show. You need to use correct value type for this call, which is itself correct. Just find out what is the correct type expected.
—SA