GetModifiedMembers returns an empty array

The code below always returns an empty array from GetModifiedMembers(object)

but dx.GetChangeSet().Updates.Contains( foo )

returns true.

DataContext dx = new DataContext( string.Empty );
MockLinqDataObject foo = new MockLinqDataObject();
dx.GetTable( foo.GetType() ).Attach( foo );

foo.PK = Guid.NewGuid();

// always returns empty array
ModifiedMemberInfo[] arr_Result = dx.GetTable( foo.GetType() ).GetModifiedMembers( foo );
bool isOk = ( arr_Result.Length == 1 );
return isOk;

      

Does anyone know what is wrong there?

Thank you in advance?

+1


source to share


2 answers


I know this is not an answer, but I have not been able to reproduce your problem.

Using the following code in a console application, I get an array of length 1:

testdbDataContext db = new testdbDataContext();
Address a = new Address();
db.GetTable(a.GetType()).Attach(a);
a.Address1 = "simple change";

var result = db.GetTable(a.GetType()).GetModifiedMembers(a);
Console.WriteLine(result.Length);
Console.ReadKey();

      



Console output 1

.

Try changing another property on the foo object and see if your result is different.

0


source


If you check the length after SubmitChanges, you get the length as 0 because the changes in the data context will be cleared after the changes are submitted.



0


source







All Articles