Can I pass table valued parameters to a stored procedure with PetaPoco?
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)
{
us开发者_运维知识库ing(var db = new Database(connection))
{
db.Fetch<UserComments>(new Sql("select UserId, Comment from Comments where UserId in (@0)", userIds);
}
}
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.
精彩评论