0

I would like to send a List<int> from my C# app as a parameter to a stored procedure in my SQL server database.

Are there any other way than parsing the List<int> in a string ? I tried with a User-Defined Table Type, but unfortunately entity framework doesn't support this type.

Thanks in advance.

Bastien
  • 994
  • 11
  • 25
  • How are you executing the SP (EF, `DbCommand` or something else)? – Richard Aug 04 '14 at 11:57
  • [This](http://stackoverflow.com/questions/8157345/entity-framework-stored-procedure-table-value-parameter) might help – Yuval Itzchakov Aug 04 '14 at 11:58
  • What t-sql type are you hoping to map the list to? – cerhart Aug 04 '14 at 11:59
  • @Richard I'm using EF to exec the SP. First I import the model and then I just execute the function automatically created during import. – Bastien Aug 04 '14 at 12:01
  • @cerhart The list will be mapped in a `WHERE something IN (MyList)`clause. Parsing it in a string works but it's ugly, slower and need T-SQL post processing. – Bastien Aug 04 '14 at 12:04
  • Create a custom table type, then pass that as a parameter to your procedure. EF support is patchy, so I use SqlCommand to execute it directly passing the value as a parameter. You could wrap this into a model partial extension class to keep it all in one box. – kidshaw Aug 04 '14 at 12:05

0 Answers0