如何使用Entity Framework在Sql Server Express中获取下一个序列号? [英] How to get the next Sequence number in Sql Server Express using Entity Framework?

查看:117
本文介绍了如何使用Entity Framework在Sql Server Express中获取下一个序列号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,Sql Server 2012(包括SQL Server Express 2012)具有如 c> SEQUENCE 功能/b/sreekarm/archive/2011/04/18/sequences-in-sql-server.aspxrel =noreferrer> here 这里 here

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

我可以得到下一个序列像这样,为SeqName选择下一个值

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

但是,如何使用实体框架5?

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

推荐答案

我使用 SqlQuery

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

这篇关于如何使用Entity Framework在Sql Server Express中获取下一个序列号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆