I can create a DataTable, and populate it with data from my list of objects, in order to use the values in my Dapper SQL. However, I see that I can remove all of that code and just use the AddTable() method of DynamicParameters:
var parameters = new DynamicParameters();
parameters.AddTable("@balances", "dbo.BalanceType", balances);
The problem is that I get an error because my Balance class has a non-primitive property: BalanceGroup.
Error:
The type of column 'BalanceGroup' is not supported.
I don't need that property in my Dapper SQL. Can I ignore that property so I can use the above approach instead of having to create a DataTable?
I've tried using Dapper.Contrib attributes of [Computed] and [Write(false)] on my object's property, but that didn't work.
Source: https://stackoverflow.com/a/43852192/279516
I also tried using ClassMapper from Dapper.Extensions, but that didn't work either.
Looks like I'll just have to use the DataTable.
Final edit: I also tried using dynamic and ExpandoObject. No dice.