How to get the next Sequence number in Sql Server Express using Entity Framework?

蹲街弑〆低调 提交于 2019-12-05 18:32:28

问题


Now that Sql Server 2012 (including SQL Server Express 2012) has SEQUENCE feature just like Oracle as explained here, here, and here.

I can get the next sequence like so, SELECT NEXT VALUE FOR SeqName

But how do I do that from my code using Entity Framework 5?


回答1:


I got it working using SqlQuery like so..

int sequence = context.Database.SqlQuery<int>("SELECT NEXT VALUE FOR MySequenceName").FirstOrDefault();


来源:https://stackoverflow.com/questions/16753149/how-to-get-the-next-sequence-number-in-sql-server-express-using-entity-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!