I wrote up a list of some of the invaluable resources I have been relying on while diving deeply into the new March CTP of Orcas.
[A DevLife post]
I wrote up a list of some of the invaluable resources I have been relying on while diving deeply into the new March CTP of Orcas.
[A DevLife post]
In a previous interation, I managed to track down some sample code that built a LINQ call to a stored procedure, the class which it returns and executed it in LINQ to SQL.
The code has changed dramatically in the March CTP. Luckily, Mike Taulty beat me to it and I leveraged the C# code in his post to revise mine.
One of the things I was so silly to do in my previous test was to hand code the return class rather than just create it in the designer and return that.
But all of this is not totally necessary since you can now drag and drop stored procs onto the LINQ to SQL Visual Modeler and make calls to it. Interestingly the return type is just created on the fly at run time so it’s not even an issue – yay to anonymous types.
However, it’s still nice to know how to build this stuff becasue drag n drop doesn’t solve every coding problem. So check Mike’s post for the C# version.
Here is a working version in VB.
“CustOrderHist” is the name of the stored procedure in my database.
What this is doing is
1) using the attribute to hook it up to the sproc
2) taking in a parameter of customerID and associating it with the parameter @CustomerID in the stored proceudre
3) Returning and IEnumerable of type CustOrderHistoryResult (the class I created in the designer that matches the structure of what the sproc returns).
On the client side, I can now take the result and do whatever I want with it, such as bind it to a gridview on a web page.
<StoredProcedure(Name:=”CustOrderHist”)> _
Public Function GetCustOrderHist(<Parameter(Name:=”CustomerID”)> ByVal customerID As String) As IEnumerable(Of CustOrderHistoryResult)
Dim result As IQueryResults(Of CustOrderHistoryResult) = _
ExecuteMethodCall(Of CustOrderHistoryResult)(Me,
MethodInfo.GetCurrentMethod, customerID)
Return result
End Function
Oh, and the cat, too.
I’ve been working from th ekitchen for about a week so I can hang out with the dogs. They don’t do stairs anymore and we haven’t cleared the path through the snow for them to get to my office from the outside.
So here they are hanging out withme. G.B. the cat has found his favorite warm spot in the house (with Tasha) and Daisy is on her cushy bed. What a mush.
