Often I meet in other projects the following.
An entity has the boolean property IsDeleting. And when deleting from the database, the object is not deleted, instead, the property IsDeleting = true. Well, respectively, all the objects for which IsDeleting = true are not displayed in the DataGrid.
Why do they do that? Is it possible that then any entity could be easily restored.
DbContext
'that you want to delete an object, and it actually deletes this and other deleted objects onSaveChanges()
. Why do other projects do this? Cost to ask them (well, or see how they use this property). In any case, immediately removing the object from the database does not make sense: communication with the database is an expensive operation, so it is better to accumulate many changes and synchronize with the database in one sitting. - VladD