我们如何从一个存储过程LINQ到SQL - 如何返回一个值(插入,更新,删除)
这里返回值是我的SP的样子:
create proc dbo.spInsertGroup
@ID uniqueidentifier
@GroupName varchar(100),
@IsActive bit
AS
BEGIN
insert into tblGroup
values(@ID, @GroupName, @IsActive)
Select @@IDENTITY AS ID
END
基于关于返回值,我想向用户展示一些反馈,其中保存是成功或失败的。
public void AddInquiry(Inquiry inq)
{
using (var transaction = new TransactionScope())
{
using (MyDataContext dc = conn.GetContext())
{
var results = dc.spInquiry_Insert(......).ToList();
transaction.Complete();
var returnValue = (int)results.ReturnValue;
// note that ReturnValue is of type object and must be cast.
}
}
}
错误:
Error 39 'System.Collections.Generic.List' does not contain a definition for 'ReturnValue' and no extension method 'ReturnValue' accepting a first argument of type 'System.Collections.Generic.List' could be found (are you missing a using directive or an assembly reference?)
错误我没有看到的返回值 – 2010-07-22 19:36:57
什么spInsertGroup的返回类型方法? 编辑:应像ISingleResult –
Equiso
2010-07-22 19:43:37