Reputation: 1107
I'm just getting my hands dirty with Dapper and loving its simplicity. I love that I can easily map the results of a SELECT procedure to a class, which was a pain to do in straight ADO and overkill using EF.
Now I'm trying to figure out how best to go the other way - to take an instance of that same class and pass it back to a stored procedure to perform and UPDATE or INSERT.
I know that Dapper supports table-valued parameters, which is good, but everything I see out there suggests that I first must construct a DataTable or SqlDataRecord collection. It's easy enough to create a helper class that will accomplish this, but it feels clunky to me. A better way?
Upvotes: 2
Views: 183
Reputation: 1064224
Right now: no, not really. However, I am interested in investigating whether we can do something by recognizing something like value-tuple arrays, so that this works:
var args = new {
id = 1, name = "abc",
someTVP = new[] {
(1, "abc", 42),
(6, "def", 84),
});
... use args with dapper
(note that this would be strictly positional - any names in the call-site are not visible to the receiver, a fundamental limitation with value-tuples)
But: to emphasize, no: this doesn't exist today. Your best bet is DataTable
.
Upvotes: 1