我有一个总是返回2个表的过程。 如何访问表中的数据? 以下是程序的一部分:
ALTER proc [dbo].[sp_Factor_Select](@FUID as varchar(31))
as
BEGIN
.
.
.
SELECT (Some Fields)
FROM tbl_Factors f
INNER JOIN tbl_Customer c ON f.fld_CustomerID_FK = c.fld_CustomerID
INNER JOIN tbl_Stores s ON s.fld_SerialNumber = f.fld_SerialNumber
WHERE f.fld_FUID = @FUID
SELECT (Some Fields)
FROM tbl_WareInfo w
WHERE w.fld_FactorID_FK = @FactorID
END
此外,我在此页面中使用以下答案:http://kishor-naik-dotnet.blogspot.com/2011/12/linq-multiple-result-set-of-procedure.html
以下是我通过上层链接帮助编写代码的部分:
[FunctionAttribute(Name = "dbo.sp_Factor_Select")]
[ResultType(typeof(tbl_Factor))]
[ResultType(typeof(tbl_WareInfo))]
public IMultipleResults GetMultipleResultSet([System.Data.Linq.Mapping.ParameterAttribute(Name = "FUID", DbType = "VarChar(31)")] string fUID)
{
try
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), fUID);
return (IMultipleResults)(result.ReturnValue);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
在这里我称之为程序:
ds_Result = db.GetMultipleResultSet(UID);
var Factor = ds_Result.GetResult<tbl_Factor>().ToList<tbl_Factor>();
var WareInfo = ds_Result.GetResult<tbl_WareInfo>().ToList<tbl_WareInfo>();
但是因为在sql中我在3个表之间的内连接中返回的程序在这行中出错:
var Factor = ds_Result.GetResult<tbl_Factor>().ToList<tbl_Factor>();
我的问题是哪个程序返回的表的类型是什么? 我应该在这写什么类型的?
[ResultType(typeof(tbl_Factor))]
[ResultType(typeof(tbl_WareInfo))]