BUY THIS BOOK
Add to Cart

Print Book $49.99


Safari Books Online

What is this?

Add to UK Cart

Print Book £30.99

What is this?

Looking to Reprint this content?

C# 3.0 in a Nutshell
C# 3.0 in a Nutshell, Third Edition A Desktop Quick Reference

By Joseph Albahari, Ben Albahari
Price: $49.99 USD
£30.99 GBP

Cover | Table of Contents | Forum


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Linq And Multiples Results Returns By A Store Procedure, How LINQPad do this ?
Trracer
post Jul 18 2008, 06:35 AM
Post #1


New Member
*

Group: Members
Posts: 4
Joined: 18-July 08
Member No.: 499



Hello,

I use a store procedure which returns multiples results from an SQL Server 2005 database. These results are "hand made" by the store procedure, not only a subset of some tables. And in this case SQLMetal don't create a data model for this kind of result (or maybe I missed something ?)

But I'm wondering how LinqPad do to retreive all results from this kind of store procedure. If I try to launch the procedure from my code I retreive only the first result...

But LinqPad retreive all types returned by the store procedure dynamically (somewhat magical, huh ? laugh.gif )

All examples I found about multiples results include an attribute [ResultType(typeof(xxx))] in the definition, but in my case the types are not defined. And I don't even know how I can retreive the types returned by the SP.

Have you any tips or example code to retreive this kind of results like LinqPad ?
Or I've to declare all possibles types returned by the store procedure manually (+/- 30) ?


Thanks !

Boris.
Go to the top of the page
 
+Quote Post
Joseph Albahari
post Jul 18 2008, 07:31 AM
Post #2


Active Member
**

Group: Members
Posts: 48
Joined: 16-February 08
Member No.: 90



Hi Boris

LINQPad actually cheats with stored procedures, and executes them into DataSets rather than using LINQ to SQL. This is precisely to allow dynamically typed results and multiple results sets. The downside of this approach is that you cannot then query the result sets as easily, because you're not getting statically typed entities back.

Note that this is different to how LINQPad handles table-valued functions (for which it maps statically typed LINQ to SQL entities, just like in SqlMetal and Visual Studio's designer). The rationale for this decision is that table-value functions always return a fixed schema (and a single result set), so it makes sense to map this to a statically typed entity class.

Joe

Go to the top of the page
 
+Quote Post
Trracer
post Jul 18 2008, 08:46 AM
Post #3


New Member
*

Group: Members
Posts: 4
Joined: 18-July 08
Member No.: 499



Ah ah ! So the only way to handle this kind of "weird" store procedure is to use "classic" dataset...

Thanks for your very quick answer !

Boris
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 28th August 2008 - 12:16 AM