Frage

I'm using Devart's Linq to Oracle components. I've got a table with a field that's updated via a sequence in the database. This works fine when inserting one row:

Dim db As New DataContext

db.MyObjects.InsertOnSubmit(MyObject)

db.SubmitChanges()

At this point, MyObject.Version will contain the version identifier that was generated in the database. So I was expecting that this code would work fine:

Dim db As New DataContext

db.MyObjects.InsertAllOnSubmit(MyObjectsList)

db.SubmitChanges()

But when I do this, the Version field is unchanged in all of the objects in MyObjectsList, even though the rows are being added to the table.

What am I missing here? Thanks in advance.

War es hilfreich?

Lösung 2

Well, I found the problem and it had nothing to do with devart. The problem turned out to be that I was passing an IEnumerable(Of MyObject) to the method, which was the result of another query. When I materialized this list to a List(Of MyObject) and passed that instead, the db generated fields did appear in my objects. I must admit I don't quite understand why this mattered, but at any rate it fixed the problem. Hope this helps someone else some time

Andere Tipps

For the database-generated value of an entity member to be retrieved when this entity is inserted, one of the following should be true:

  • the 'Auto Generated Value' property of this member is set to true;
  • the 'Auto-Sync' property of this member is set to 'OnInsert' or 'Always'.

Please check that either of these conditions is satisfied. Also, please try updating to the 6.30.160 version of dotConnect for Oracle (if you are using a prior build).

If the problem persists, could you please send us a test project with which it can be reproduced?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top