C# 从linq中的存储过程返回scopeidentity到sql

C# 从linq中的存储过程返回scopeidentity到sql,c#,linq-to-sql,C#,Linq To Sql,我有一个正在返回scopeidentity的存储过程。我将表和存储过程放到dbml中。函数的返回类型为 return ((ISingleResult<storedocumentResult>)(result.ReturnValue)); return((IsingResult)(result.ReturnValue)); 在C代码中,我使用datacontext通过存储过程向表中插入一个新条目。我需要将scopeidentity返回给调用方法,但我不知道如何访问它 ISingle

我有一个正在返回scopeidentity的存储过程。我将表和存储过程放到dbml中。函数的返回类型为

return ((ISingleResult<storedocumentResult>)(result.ReturnValue));
return((IsingResult)(result.ReturnValue));
在C代码中,我使用datacontext通过存储过程向表中插入一个新条目。我需要将scopeidentity返回给调用方法,但我不知道如何访问它

ISingleResult<storedocumentResult> result = dbc.storedocument(doc.DocumentName, doc.FileExtension);
IsingResult结果=dbc.storedocument(doc.DocumentName,doc.FileExtension);
它将位于中(即
对象),或通过
结果.Single().Foo
,其中
Foo
是(生成的)
storedocumentResult
上的某个属性

如果是前者,请注意
SCOPE\u IDENTITY()
numeric(38,0)
,因此您可能需要
int id=(int)(decimal)result.ReturnValue以正确执行强制转换和转换