Using Linq-to-Sql:
MyClass obj;
...
// need to delete this object
dataContext.GetTable(obj.GetType()).DeleteOnSubmit(obj);
BUT
I don't know whether or not obj
has been attached to the data context. And if it hasn't, that last call to DeleteOnSubmit throws an exception.
There has to be an easy way of telling whether obj
is attached to dataContext
- but I can't see anything obvious.
How do you do it?