Getting NEXTVAL from sequence

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Ray.Henry
Posts: 2
Joined: Mon 29 Mar 2010 22:04

Getting NEXTVAL from sequence

Post by Ray.Henry » Thu 12 Aug 2010 19:41

Hi,

Is there a way in dotConnect for ORACLE and EF to have the key value be populated automatically from a SEQUENCE?

I don't have control over the tables so I can't add a trigger to do this.

I can probably figure out a way to extract the connection string from the EF model and create a normal ADO.NET connection to get the NEXTVAL and then populate it in my entity prior to saving...

But, it would be nice if there was a way to put it in the model.

Thank you! Great product!

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 13 Aug 2010 13:05

You have two alternatives.
The first way is to write three CommandTexts in the model for update, insert and delete (write the necessary SQL commands in these CommandTexts and map them as Insert/Update/Delete commands in the Configure Behaviour window).
The other way is to set the values for Entity Key using ADO.NET SQL command. Here is a simple way to get the store connection from ObjectContext:

Code: Select all

OracleConnection conn = (db.Connection as EntityConnection).StoreConnection as OracleConnection;

Post Reply