private void ResolveDelete()
 {
     if (!trackedObject.IsDeleted)
     {
         trackedObject.ConvertToDeleted();
     }
     trackedObject.AcceptChanges();
     isResolved = true;
 }
Exemple #2
0
        /// <summary>
        /// Puts an entity from this table into a pending delete state.
        /// </summary>
        /// <param name="entity">The entity to be deleted.</param>
        public void DeleteOnSubmit(TEntity entity)
        {
            if (entity == null)
            {
                throw Error.ArgumentNull("entity");
            }
            CheckReadOnly();
            context.CheckNotInSubmitChanges();
            context.VerifyTrackingEnabled();
            TrackedObject trackedObject = context.Services.ChangeTracker.GetTrackedObject(entity);

            if (trackedObject == null)
            {
                throw Error.CannotRemoveUnattachedEntity();
            }
            if (trackedObject.IsNew)
            {
                trackedObject.ConvertToRemoved();
            }
            else if (trackedObject.IsPossiblyModified || trackedObject.IsModified)
            {
                trackedObject.ConvertToDeleted();
            }
        }