有没有办法也修改 dbml 以使 Designer.cs 中的方法保持为 IMultipleResults?
我有一个返回 2 组数据的存储过程。当我将程序拖放到dbml、xml和dbml生成的designer.cs时
<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));
}
为了获得多个结果,我将 Designer.cs 修改为:
[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);
}
这工作正常,但由于 dbml,当我添加更多内容并将方法保存在 Designer.cs 中时,它会恢复为 ISingleResult 之一。