I’ve been looking at converting one of our existing WebApi site to ASP.Net core. One issue that I found is that we us Table Value Parameters (TVP) in our sql server stored procedures.
In .Net 4.6 Dapper uses DataTables and the .AsTableValuedParameter helper method. DataTables don’t exist in .Net core which means that we have an issue.
What I found is that you can go back to what appears to be the original way that Dapper supported TVPs and create a class that implements IDaynamicParameters.
1 | public class EmailAddressesParameter : SqlMapper.IDynamicParameters |
Then you call it like this.
1 | using (var connection = new SqlConnection(connectionString)) |
It has a slight downside that you need to create a new class for each TVP you use. I don’t think that is too big of a deal as it would be a one time set up.