Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top