Esempio n. 1
0
 public void AddAction(EntityInsertAction action)
 {
     insertions.Add(action);
 }
Esempio n. 2
0
			private bool IsProcessedAfterAllAssociatedEntities(EntityInsertAction action, int latestBatchNumberForType)
			{
				var propertyValues = action.State;
				var propertyTypes = action.Persister.ClassMetadata.PropertyTypes;

				for (var i = 0; i < propertyValues.Length; i++)
				{
					var value = propertyValues[i];
					var type = propertyTypes[i];

					if (type.IsEntityType &&
						value != null)
					{
						// find the batch number associated with the current association, if any.
						int associationBatchNumber;
						if (_entityBatchNumber.TryGetValue(value, out associationBatchNumber) &&
							associationBatchNumber > latestBatchNumberForType)
						{
							return false;
						}
					}
				}

				return true;
			}
Esempio n. 3
0
			private void AddToBatch(int batchNumber, EntityInsertAction action)
			{
				List<EntityInsertAction> actions;

				if (!_actionBatches.TryGetValue(batchNumber, out actions))
				{
					actions = new List<EntityInsertAction>();
					_actionBatches[batchNumber] = actions;
				}

				actions.Add(action);
			}
Esempio n. 4
0
			private int GetBatchNumber(EntityInsertAction action, string entityName)
			{
				int batchNumber;
				if (_latestBatches.TryGetValue(entityName, out batchNumber))
				{
					// There is already an existing batch for this type of entity.
					// Check to see if the latest batch is acceptable.
					if (IsProcessedAfterAllAssociatedEntities(action, batchNumber))
						return batchNumber;
				}
				
				// add an entry for this type of entity.
				// we can be assured that all referenced entities have already
				// been processed,
				// so specify that this entity is with the latest batch.
				// doing the batch number before adding the name to the list is
				// a faster way to get an accurate number.

				batchNumber = _actionBatches.Count;
				_latestBatches[entityName] = batchNumber;
				return batchNumber;
			}