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 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();
}
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.