I'm using FastMember
to convert a List<T>
to a Datatable
. Some classes contain enums and this is causing problems when passing the datatables as a TVP to a stored procedure.
public class MyObject
{
public int Id {get; set;}
public SomeEnum EnumHere {get; set;}
}
var dt = new DataTable();
using (var reader = ObjectReader.Create(myObjectsList))
{
dt.Load(reader);
}
db.Execute<ResultObject>("insert_objects", new { dt }, commandType: CommandType.StoredProcedure);
FastMember
converts the list, however the column for the enum has a DataType
of SomeEnum
. When passing the datatable as a TVP, the following exception is thrown:
Exception thrown: 'System.ArgumentException' in Dapper.dll
Additional information: The type of column 'SomeEnum' is not supported. The type is 'SomeEnum'
Is there a way to force FastMember
to convert enums to int?