2

I'm trying to use PetaPoco for a project that has some stored procedures. Most of them work fine, however, we have a couple where the stored procedure is expecting an IntList which is a User-Defined Table Type.

I haven't found a way to do this, and I hope I'm just missing something obvious. The current work around that I have is to copy the stored procedure code from SQL into a string and then execute that against my PetaPoco database:

public IEnumerable<UserComments> GetComments(IEnumerable<int> userIds)
{
   using(var db = new Database(connection))
   {
      db.Fetch<UserComments>(new Sql("select UserId, Comment from Comments where UserId in    (@0)", userIds);
   }
}
taylonr
  • 10,732
  • 5
  • 37
  • 66
  • 1
    How would you normally call it through ado.net? – Schotime Jul 21 '11 at 12:53
  • Did You get PetaPoco to working with TableValue Param When I try pass sqlparam I alway get error Column, parameter, or variable @0. : Cannot find data type Structured. Can You show how call fetch with table value param. – adopilot Jun 08 '13 at 13:14
  • I think I did, but since it's been almost 2 years now, I don't even know what code I was working on, so I can't give you much help – taylonr Jun 08 '13 at 20:56
  • Thank You any way here is my problem/solution http://stackoverflow.com/questions/17019412/pass-table-value-param-to-stored-procedure-using-petapoco – adopilot Jun 10 '13 at 11:09

1 Answers1

4

You can pass a SqlParameter directly in. eg

db.Fetch<User>("EXECUTE getUser @0", new SqlParameter(,,,,));

So you should be able to call it like you would directly through ADO.net.

sasharz
  • 780
  • 5
  • 8
Schotime
  • 15,707
  • 10
  • 46
  • 75