I'm using VB.NET. I am creating extremely dynamic sql expressions being fed into a stored proc that is little more than an EXECUTE wrapper. I will feed in the table and column names as parameters. Then whatever is being returned (which would be a recordset
in old money), I'd like to cycle through it. Unfortunately I can't drag the tables onto my DBML and have them strongly typed.
What is the Type, or Object that I catch the records into that I can then cycle through (with a for each loop) ??
johngccfc
Member
12 Points
24 Posts
Linq datacontext with dynamic sql returning 'some list of other'
Jul 07, 2008 08:00 PM|LINK
Hi,
I'm using VB.NET. I am creating extremely dynamic sql expressions being fed into a stored proc that is little more than an EXECUTE wrapper. I will feed in the table and column names as parameters. Then whatever is being returned (which would be a recordset in old money), I'd like to cycle through it. Unfortunately I can't drag the tables onto my DBML and have them strongly typed.
What is the Type, or Object that I catch the records into that I can then cycle through (with a for each loop) ??
someWayOfCatchingTheReturnedRecords = myDataContext.myStoredProc(VeryVariableStringWhichNeedsExecuting)
Thanks
marcind
Contributor
3344 Points
609 Posts
Microsoft
Re: Linq datacontext with dynamic sql returning 'some list of other'
Jul 07, 2008 08:57 PM|LINK
Hi John,
have a look at this blog post by Scott Guthrie (in the "Handling multiple result shapes from SPROCs" section).
ASP.NET Team
@marcind
Blog
johngccfc
Member
12 Points
24 Posts
Re: Linq datacontext with dynamic sql returning 'some list of other'
Jul 07, 2008 09:40 PM|LINK
Thanks for the reply. Excuse my possibly dim response. I'm pretty new to Linq.
Doesn't this rely on the fact that Products or Orders are going to be returned and they already 'belong'.
I'm hoping to find something that would accomodate the fact that some quantity of some type of records were returned, and we won't know what they are.
However, as they are a bunch of returned records, they could be cycled through as they are records and records can be cycled through.
i.e. in that example, could I use;
For Each result in IMultipleResults
' do my stuff
Next
And leave the fact that they may be products or orders or widgets completely undermined?
Thanks