i have a table which i use to implement a开发者_StackOverflow中文版 sequence in Sql Server 2008. The sequence table has just 1 column which is an integer.
I want to know if i can do something like this
update dbo.MySequence set val=val+1 output inserted.val
and return value without using stored procedures in Entity Framework.
Thanks.
Why to avoid stored procedures? Using stored procedures is part of using EF. You don't have to create stored procedure but you still have to call direct SQL (for example with context.ExecuteStoreQuery
). For example on MS SQL you can use:
DECLARE @val INT
UPDATE dbo.MySequence SET @val = val = val + 1
SELECT @val
But it is better to have sequences named (with additional column).
精彩评论