I'm using visual studio 2008 and I've created a stored procedure that selects back two different result sets. I drag the stored proc on to a linq to sql dbml datacontext class, causing visual studio to create the following code in the cs file:
[Function(Name="dbo.List_MultiSelect")]
public ISingleResult<开发者_JAVA百科DataAccessLayer.DataEntities.List_MultiSelectResult> List_MultiSelect()
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())));
return ((ISingleResult<DataAccessLayer.DataEntities.List_MultiSelectResult>)(result.ReturnValue));
}
Shouldn't the designer generate the code to use IMultipleResults? Or do I have to hand code that?
Using the designer will return an ISingleResult
while using SqlMetal will generate the IMultipleResult
that you expect. Otherwise, yes, you'll likely have to jump in there and tweak it directly.
An easy way would be to use SqlMetal then copy/paste the code it generates. Bear in mind that pasting it into the designer code might not be ideal since subsequent code generation will overwrite it. Perhaps you can move the relevant code to a partial class to avoid this issue.
My detailed answer here addresses this issue: SqlMetal wrongly generates the return type of my stored proc (LINQ)
精彩评论