/// <summary> /// Stores an entity instance to the database. /// </summary> /// <param name="entity"> /// The entity to store. /// </param> /// <param name="behaviors"> /// The behaviors. /// </param> /// <typeparam name="T"> /// The entity type. /// </typeparam> public void Persist <T>(T entity, Behaviors behaviors) where T : class { if (behaviors.IsCreateNew() && !behaviors.DoNotCache() && !behaviors.BypassWriteCache()) { var entityReference = this.EntityReferenceForType(entity.GetType()); if (entityReference != null) { bool newEntity; var key = entityReference.GetKeyFromEntity(entity, out newEntity); if (!newEntity) { var entitySpec = new EntitySpec(entityReference, key); this.entitySpecsWritten.Remove(entitySpec); } } } EntityWriter.Persist(this, entity, behaviors); }