2

I would like to get nextvalue of sequence in postgresql in my controller.

I wrote a Custom Query, but I need to set it as Id (which is integer type).

How can I do that or I should write custom insert query too?

int count = session.CreateSQLQuery("SELECT nextval('transport_id_seq')");
Justina Seliokaite
  • 55
  • 1
  • 3
  • 10

1 Answers1

4

As @Craig Ringer says, just execute the query:

var count = session.CreateSQLQuery("SELECT nextval('transport_id_seq')")
    .UniqueResult<long>();
Najera
  • 2,869
  • 3
  • 28
  • 52