Can I check wheter Linq 2 SQL's DataContext is tracking entities?
Posted
by Thomas Jespersen
on Stack Overflow
See other posts from Stack Overflow
or by Thomas Jespersen
Published on 2008-11-06T10:52:35Z
Indexed on
2010/06/06
4:02 UTC
Read the original article
Hit count: 407
c#
|linq-to-sql
We want to throw an exception, if a user calls DataContext.SubmitChanges() and the DataContext is not tracking anything.
That is... it is OK to call SubmitChanges if there are no inserts, updates or deletes. But we want to ensure that the developer didn't forget to attach the entity to the DataContext.
Even better... is it possible to get a collection of all entities that the DataContext is tracking (including those that are not changed)?
PS: The last question I asked were answered with: "do it this way instead"... please don't :-)
© Stack Overflow or respective owner