how do i execute a stored procedure with vici coolstorage?

413 views Asked by At

I'm building an app around Vici Coolstorage (asp.net version). I have my classes created and mapped to my database tables and can pull a list of all records fine.

I've written a stored procedure where the query jumps across databases that aren't mapped with Coolstorage, however, the fields in the query result map directly to one of my classes. The procedure takes 1 parameter.

so 2 questions here:

how do i execute the stored procedure? i'm doing this

CSParameterCollection collection = new CSParameterCollection();
collection.Add("@id", id);
var result = Vici.CoolStorage.CSDatabase.RunQuery("procedurename", collection);

and getting the exception "Incorrect syntax near 'procedurename'." (i'm guessing this is because it's trying to execute it as text rather than a procedure?)

and also, since the class representing my table is defined as abstract, how do i specify that result should create a list of MyTable objects instead of generic or dynamic or whatever objects? if i try

Vici.CoolStorage.CSDatabase.RunQuery<MyTable>(...)

the compiler yells at me for it being an abstract class.

1

There are 1 answers

0
Philippe Leybaert On BEST ANSWER

There's a shortcut in CoolStorage to run a stored procedure. Simply prefix the stored procedure name with "!":

 CSDatabase.RunQuery("!procedurename", collection);