I use linq 2 sql for my ORM.
For performance reasons, I serialize some of them, and throw them into memcached.
When they're deserialized, they're of course not attached to a datacontext, which is 100% fine, as they're only used for reading from in those scenarios.
For sanity reasons however, I'd like to be able to tell whether a given object is attached to a datacontext (fetched from the db), or not (fetched from memcached).
Any ideas?
Thanks.
Use GetOriginalEntityState. Here's a test.
Customer cust = new Customer(); ctx.Customers.Attach(cust); Customer orig = ctx.Customers.GetOriginalEntityState(cust); //test if orig is null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With