Page 1 of 1

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

Posted: Fri 02 Nov 2012 09:00
by fphilipsen
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).

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

Posted: Fri 02 Nov 2012 14:20
by MariiaI
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

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

Posted: Mon 12 Nov 2012 09:38
by fphilipsen
Any progress on this? Will this be fixed in the next dotConnect release/update?

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

Posted: Tue 13 Nov 2012 13:32
by MariiaI
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.

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

Posted: Wed 28 Nov 2012 10:10
by MariiaI
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.

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

Posted: Fri 30 Nov 2012 07:47
by MariiaI
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