I use FastMember to convert a List<T> to Datatable . Some classes contain enumerations, and this causes problems when transferring data in the form of 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 to enumerate has a DataType of SomeEnum . When transmitting data such as TVP, the following exception is thrown:
Exception thrown: "System.ArgumentException" in Dapper.dll
Additional Information: The column type "SomeEnum" is not supported. Type "SomeEnum"
Is there a way to get FastMember convert enums to int?
source share