0

I'm calling a stored proc that takes table-valued parameter.

I know the following options for passing this parameter: create DataTable, DbDataReader, or IList<SqlDataRecord>.

I'm using IList<SqlDataRecord> (using DataTable is similar), but it involves writing tons of boilerplate code: create collection, set types of each the columns, add rows, set value of each cell.

I think that is exactly the type of code that Entity Framework is supposed to automate. So I hoped to define C# class matching SQL TVP type, add usual EF attributes, create collection of those objects and let EF implement DbDataReader or IList<SqlDataRecord> on top of my collection. But I cannot find any way to do it - e.g. there is EntityDataReader, but that's for reading from SQL - there is no implementation I can find that implements any of the suitable interfaces on top of in-memory collection.

Any suggestions, before I start writing it myself using Reflection?

M4N
  • 94,805
  • 45
  • 217
  • 260
Michael Entin
  • 7,189
  • 3
  • 21
  • 26
  • Related to this question - check out my answer (basically I did the reflection bit + allowed for extra config): http://stackoverflow.com/questions/8157345/entity-framework-stored-procedure-table-value-parameter – Toby Couchman Jun 16 '14 at 11:43

1 Answers1

1

Entity Framework does not currently support table valued parameters. You can vote here for this feature: http://data.uservoice.com/forums/72025-ado-net-entity-framework-ef-feature-suggestions/suggestions/1015347-table-valued-parameters

Pawel
  • 31,342
  • 4
  • 73
  • 104