Is there any way to also modify dbml so that the method in designer.cs stays as IMultipleResults?
I have a stored procedure that returns 2 sets of data. When I drag & drop the procedure to dbml, xml and designer.cs generated by dbml
<Function Name="dbo.MultiResultsTest" Method="MultiResultsTest">
<Parameter Name="iCustomerID" Type="System.Int32" DbType="Int" />
<Parameter Name="iProductID" Type="System.Int32" DbType="Int" />
<ElementType Name="MultiResultsTestResult">
<Column Name="CustomerID" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
<Column Name="Name" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
<Column Name="Phone" Type="System.String" DbType="VarChar(14)" CanBeNull="true" />
<Column Name="Email" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
<Column Name="Address" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
</ElementType>
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.MultiResultsTest")]
public ISingleResult<MultiResultsTestResult> MultiResultsTest([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> iCustomerID, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> iProductID)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iCustomerID, iProductID);
return ((ISingleResult<MultiResultsTestResult>)(result.ReturnValue));
}
And to get the multiple results I modified the designer.cs to like this:
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.MultiResultsTest")]
[ResultType(typeof(Customer))]
[ResultType(typeof(Product))]
public IMultipleResults MultiResultsTest([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> iCustomerID, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> iProductID)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iCustomerID, iProductID);
return (IMultipleResults)(result.ReturnValue);
}
This works fine but because of the dbml, when I add more to it and save the method in designer.cs reverts back to the ISingleResult one.
After bit of searching and trying I found this way works!
This generates the following method in designer.cs