Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
fphilipsen
Posts: 14
Joined: Thu 05 Jul 2012 10:29

Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Post by fphilipsen » Fri 02 Nov 2012 09:00

A call to Attach(entity, bool) and subsequently SubmitChanges does not seem to generate the expected UPDATE SQL.

Code: Select all

var newRecord = new TEST();
newRecord.ID = 1;
newRecord.FIRSTNAME = "Some";
newRecord.LASTNAME = "Two";

using (var context = GetDataContext())
{
  context.TESTs.Attach(newRecord, true);
  //ChangeSet changeSet = context.GetChangeSet();
  context.SubmitChanges();
}
I create a separate (out of context) instance of my entity with the proper assignment of values (ID etc.). For a specific context I attach the new instance with Attach(entity, bool) and then call SubmitChanges(). If I check the logs I don't see any generated UPDATE SQL query.

That said, if I look up the entity I want to change in the context scope first and call Attach(entity, original) then it does work.

Code: Select all

var newRecord = new TEST();
newRecord.ID = 1;
newRecord.FIRSTNAME = "Some";
newRecord.LASTNAME = "Two";

using (var context = GetDataContext())
{
  var record = context.TESTs.FirstOrDefault(o => o.ID == 1);

  context.TESTs.Attach(newRecord, record);
  //ChangeSet changeSet = context.GetChangeSet();
  context.SubmitChanges();
}
If I check the ChangeSet object (retrieved through context.GetChangeSet()) I see an updated record in both cases.

A call to Attach(entity, bool) did work for previous versions of dotConnect that we have used (i.e. 6.80). We are now using 7.2.77. Has anything changed in the latest version regarding Attach(entity, bool)..are there any other settings required for this to work?

Note 1: All properties in the model/lqml are set to Update Check = Never.
Note 2: No exception is thrown. There simply isn't any UPDATE SQL generated and thus no change in the database (obviously).

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Post by MariiaI » Fri 02 Nov 2012 14:20

Thank you for the report. This is a known issue and we are investigating it now. We will inform you about the results as soon as possible.
As a workaround, you could use the Attach(TEntity,TEntity) method, as described in your post, or use the InsertOnSubmit() method for inserting new data.
http://www.devart.com/linqconnect/docs/ ... ubmit.html

fphilipsen
Posts: 14
Joined: Thu 05 Jul 2012 10:29

Re: Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Post by fphilipsen » Mon 12 Nov 2012 09:38

Any progress on this? Will this be fixed in the next dotConnect release/update?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Post by MariiaI » Tue 13 Nov 2012 13:32

We are working on this issue now. We will definitely inform you when it is fixed. Presumably, this fix should be included in one of the next builds of dotConnect for Oracle, in several weeks.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Post by MariiaI » Wed 28 Nov 2012 10:10

The bug with the Attach(TEntity,Boolean) method has been fixed. The fix will be available in the next build of dotConnect for Oracle, which we plan to release this week. We will inform you when it is available for download.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.

Post by MariiaI » Fri 30 Nov 2012 07:47

New version of dotConnect for Oracle 7.3 is released!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=25388

Post Reply