如何在C#程序中访问Special Select SQL Query的输出值

时间:2012-01-21 18:45:06

标签: linq sql-server-2008 c#-4.0

我编写C#,并使用Linq访问数据库。 我写下面的商店程序,但我不知道,如何在我的程序中访问该返回值。帮我怎么做???

GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

Create Procedure [dbo].[StrPC_BDPathData_CustomSelectDistance]
    @PkPathData_Id int
As
Begin
    Select [Dstc]
    From BDPathData
    Where
        [PkPathData_Id] = @PkPathData_Id
End

所以在我的程序中使用此代码:

DataClassesDataContext data = new DataClassesDataContext();
int Distance =int.Parse(data.StrPC_BDPathData_CustomSelectDistance(10));

但距离值没有变化,请帮忙......

1 个答案:

答案 0 :(得分:0)

这取决于你如何映射ORM中的东西,但你可能想要这样的东西:

DataClassesDataContext data = new DataClassesDataContext();
var Results = data.StrPC_BDPathData_CustomSelectDistance(10);
int Distance =int.Parse(Results(0).Dstc);