/// <summary> /// Checks whether the provided entity is current in the data store. /// </summary> /// <param name="entity">The entity to look for in the data store.</param> /// <returns>A boolean value indicating whether the provided entity was found in the data store.</returns> public override bool IsStored(IEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (ObjectContainer == null) { throw new InvalidOperationException("The ObjectContainer has not been initialized."); } bool foundBound = ObjectContainer.Ext().IsStored(entity); if (foundBound) { return(true); } else { bool foundByID = (Reader.GetEntity(entity.GetType(), "ID", entity.ID) != null); return(foundByID); } }
public override void Commit(bool forceCommit) { using (LogGroup logGroup = LogGroup.StartDebug("Committing the data store (or adding to batch for later).")) { // Only commit if there's no batch running if (forceCommit || !BatchState.IsRunning) { LogWriter.Debug("No batch running. Committing immediately."); if (ObjectContainer != null) { if (!ObjectContainer.Ext().IsClosed()) { LogWriter.Debug("Committing."); ObjectContainer.Commit(); RaiseCommitted(); } else { LogWriter.Debug("Can't commit. The data store is closed."); } } else { throw new InvalidOperationException("ObjectContainer == null"); } } // If a batch is running then the commit should be skipped. It'll be commit once the batch is complete. else { LogWriter.Debug("Batch running. Adding data source to batch. It will be committed when the batch is over."); BatchState.Handle(this); } } }
public override void Refresh(TEntity entity) { ObjectContainer.Ext().Refresh(entity, 0); }
public override void Detach(TEntity entity) { ObjectContainer.Ext().Purge(entity); }