Attach(entity, bool) + SubmitChanges does not generate UPDATE SQL.
Posted: Fri 02 Nov 2012 09:00
A call to Attach(entity, bool) and subsequently SubmitChanges does not seem to generate the expected UPDATE SQL.
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.
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).
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();
}
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();
}
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).