score:-1

I wonder what this would do

 var old = (Foo)real;

I'm wondering if the instance itself is creating the connection

score:2

Your analysis is correct. Your assignments are establishing links.

You can modify the generated code to not do this (or write your own). But this means you have to live without auto-generated entity classes. I personally consider this to be unacceptable.

Why don't you serialize the pre-image object into a dictionary? Or copy its property values into a custom DTO class?

From your code I can tell that you want the old values to do change logging. You can do that using

DataContext.GetTable<T>().GetModifiedMembers(entity)

Related Articles