Problem getting data after insert

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Patroklo
Posts: 3
Joined: Mon 10 Nov 2008 13:04

Problem getting data after insert

Post by Patroklo » Tue 22 Sep 2009 10:58

I'm using linq to oracle with the dotconnect for oracle and i'm inserting some data in a oracle table. I want to get the id that the table gives with a trigger to that column, so I have searched in the internet and got a code for linq to sql that I have tried but it always gives me a 0 as the new id of the row that I have just inserted when the table it's not empty, so clearly it doesn't get the data from the database.

The code that I am using is:

'here I make the variable that i'm going to insert in the table TObject
Dim inserto As New Csicontext.TObject

'I create de linq variable
dim oraclelinq as New Csicontext.Csidatacontext

'I give the variable some data to insert
With inserto

.IdAplicacion = idaplicacion
.Descripcion = descripcion
.Activo = "a"
End With

'I insert the data in the table
oraclelinq.TObjetos.InsertOnSubmit(inserto)
oraclelinq.SubmitChanges()
'And in this step I am supposed to get the id from the table of oracle, but only gives a '0'
Return inserto.IdObject

I am doing anything wrong or in linq to oracle that it's still not suported?

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

Post by AndreyR » Tue 22 Sep 2009 11:19

Please make sure that you have set the Auto Generated Value property to true for your Primary Key column.
Also set the AutoSync property value to OnInsert for obtaining the value of the generated ID in the code after the data is inserted.

Post Reply