RuntimeShapesforResults")]
public ISingleResult
RuntimeShapesforResults([Parameter(DbType
= "NVarChar(20)")] string param)
{
IExecuteResult result = this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())), param);
return ((ISingleResult)(result.ReturnValue));
}
The previous method used the ISingleResult interface, which is of type, Items.
Using the above method, we can execute stored procedure by passing the parameter
value, shown as follows:
// Stored procedure which returns single resultset
ISingleResult result =
db.SelectItemDetails("Chocolate Fudge Icecream");
foreach (Items item in result)
{
Console.WriteLine(item.Name + item.CategoryID);
}
ISingleResult, which is of the type Items is used here to store the result that is
returned by the stored procedure. Then we can use a variable of type Items and loop
through the returned result to get the output as we want. The following screenshot
shows you this:
LINQ to SQL
[ 114 ]
We will have another stored procedure that returns two result-sets.
Pages:
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192