private void SaveForType(IEntity entity, Type type, ITransaction tx) { EntityInfo entityInfo = CacheManager.GetEntityInfo(type); if (entityInfo == null) { return; } ProcessNonIdentifyingRelations(entity, entityInfo); ITypeFieldValueList fieldValues = OperationUtils.ExtractEntityTypeFieldValues(entity, type); if (entity.Status == EntityStatus.Unmodified) { //do nothing } else if (entity.Status == EntityStatus.New) { Insert(entity, fieldValues, type, tx); } else if (entity.Status == EntityStatus.Modified) { if (entityInfo.TableInfo.VerifyOnWriteStrategy == VerifyOnWriteStrategy.Verify) { if (!VersionValidated(entity, type, tx)) { throw new DataUpdatedFromAnotherSourceException(String.Format("The type {0} updated from another transaction", type)); } OperationUtils.IncrementVersion(fieldValues); SetValues(entity, fieldValues); } Update(entity, fieldValues, type, tx); } else if (entity.Status == EntityStatus.Deleted) { Delete(fieldValues, type, tx); } else { string message = String.Format("In-corret status for class {0}", type.FullName); throw new IncorrectStatusException(message); } fieldValues = OperationUtils.ExtractEntityTypeFieldValues(entity, type); IEntityContext entityContext = entity.Context; if (entityContext != null) { entityContext.ChangeTracker.AddFields(fieldValues.FieldValues); } entity.Context.AddToCurrentObjectGraphIndex(entity); ProcessIdentifyingRelations(entity, type, tx, entityInfo, fieldValues); }