Prev | Current Page 182 | Next

Satheesh, N Kumar

"LINQ Quickly"


To access the results after execution, we have to use the GetResult method of
MultipleResults, shown as follows:
IMultipleResults results = db.MultipleResults();
// First Result set which is of type Categories
foreach (Categories Cats in results.GetResult())
{
Console.WriteLine("Cateegory:" + Cats.Category);
}
// Second result set which is of type Items
foreach (Items itms in results.GetResult())
{
Console.WriteLine("Item Name:" + itms.Name +" Category:" +
itms.Categories.Description);
}
Chapter 4
[ 115 ]
The first foreach loop will refer to the first result-set of the stored procedure, and
the second, will return the second result-set of the stored procedure.
Let us create another stored procedure which will return a result-set. Here the
result-set is not pre-defined. It is based on the value passed to the input parameter.
Let us see how we can define and access a stored procedure through LINQ. The text
for the stored procedure is as follows:
CREATE PROCEDURE [dbo].


Pages:
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
Praca dla pielegniarek fotele i krzesła biurowe olej manuka lampy ogrodowe Apartamenty Novalja