Stored procedure:
CREATE PROCEDURE spIn
(@value1 varchar(100),
@value2 varchar(100),)
AS
BEGIN
INSERT INTO dbo.In(value1, value2,)
VALUES (@value1, @value2,)
END
RETURN SCOPE_IDENTITY()
GO
In code it is like
using (DBEntities dataContext = new DBEntities())
{
dataContext.spIn(value1,value2);
}
How to store the identity value??
FYI while function import I have given as Scalars of type Int32
, if I check the column information no column is there.
I have changed the stored procedure like this:
CREATE PROCEDURE spIn
(@value1 varchar(100),
@value2 varchar(100),)
AS
BEGIN
INSERT INTO dbo.In(value1, value2,)
VALUES (@value1, @value2,)
END
SELECT @@IDENTITY AS id
GO
and the code change is as below
using (DBEntities dataContext = new DBEntities())
{
int = ID Convert.ToInt32(dataContext.spIn(value1,value2).FirstOrDefault().id);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.