problem about Table<T>.Attach(object, bool)

problem about Table<T>.Attach(object, bool)

Postby windwolf » Fri 13 Aug 2010 06:54

Hello.
I have a table named "LinqTest", which has a Primary Key column called "ID" and a Version column called "VERSION_".
Code: Select all
CREATE TABLE .LINQTEST
(
  ID        VARCHAR2(50),
  NAME   VARCHAR2(20),
  AGE       NUMBER(38),
  VERSION_  NUMBER(38),
  MASTCODE  VARCHAR2(50)
)

Step 1: I query one entity form a instance of DataContext.
Step 2: Modify the Name of the entity, while query form step 1.
Step 3: Attach the entity with another instance of DataContext by call Table.Attach(T, bool) with true as second parameter.
Step 4: SubmitChanges.
Code: Select all
Linqtest ent = null;
using (var ctx = new TestDataContext ())
{
                var linq = from c in ctx.GetTable()
                           where c.Id == "1607"
                           select c;
                ent = linq.FirstOrDefault();
}
ent.Name = "asdfasdf1";
using (var ctx2 = new TestDataContext ())
{
                ctx2.GetTable().Attach(ent, true);
                //var m = ctx2.GetTable().GetModifiedMembers(ent);
                ctx2.SubmitChanges();
}

Then, throw a Exception.
Value of member 'Id' of an object of type 'Linqtest' changed.
A member defining the identity of the object cannot be changed.
Consider adding a new object with new identity and deleting the existing one instead.
Devart.Data.Linq.r.a(k A_0, ac A_1, Object A_2, Boolean A_3)
Devart.Data.Linq.y.a(r A_0, ac A_1, Boolean A_2)
Devart.Data.Linq.y.a(DataContext A_0, ConflictMode A_1)
Devart.Data.Linq.y.b(DataContext A_0, ConflictMode A_1)
Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
Devart.Data.Linq.DataContext.SubmitChanges()


So i check the modified members before submit. I find that, all fields except VERSION_ (include ID) are in the array of modified members.

The same code run well in Linq to SQL.

I guess that, there is something wrong in my code. or some bugs in the library.

I need a solution to solve this problem. thanks.
windwolf
 
Posts: 1
Joined: Fri 13 Aug 2010 05:48

Postby StanislavK » Tue 17 Aug 2010 12:03

Thank you for your report, we've reproduced the issue. We will inform you when it is fixed.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby StanislavK » Thu 14 Oct 2010 15:50

We have fixed the problem. The fix is available in the new 5.70.180 build of dotConnect for Oracle. You can download it from
http://www.devart.com/dotconnect/oracle/download.html
(the trial version only) or from Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/

For more information about the improvements and fixes available in dotConnect for Oracle 5.70.180, please refer to
http://www.devart.com/forums/viewtopic.php?t=19236
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to dotConnect for Oracle