Search code examples
c#asp.net-mvcenumslinq-to-excel

Mapping/Transformation to handle Enum model with LinqToExcel


I'm having an issue handling one column of the Excel file I'm trying to import to my database. The property refers to an Enum model. I tried putting integers values (referring to the Enum index) or the string value themselves but obviously it doesn't work.

How would I go about handling this using (I assume) the AddTransformation method?


Solution

  • The solution was to create a new object and map the property manually. The Enum was handled this way:

    MyEnumProperty = (MyEnumProperty)Convert.ToInt32(c["ColumnNameInExcel"])