protected bool Equals(RelationshipEntityInstanceBuilderIdentity other) { if (_keyPropertyValues.Length != other._keyPropertyValues.Length) { return false; } for (var keyValueIndex = 0; keyValueIndex < _keyPropertyValues.Length; keyValueIndex++) { var currentKeyValue = _keyPropertyValues[keyValueIndex]; var otherKeyValue = other._keyPropertyValues[keyValueIndex]; if (!object.Equals(currentKeyValue, otherKeyValue)) { return false; } } return true; }
protected bool Equals(RelationshipEntityInstanceBuilderIdentity other) { if (_keyPropertyValues.Length != other._keyPropertyValues.Length) { return(false); } for (var keyValueIndex = 0; keyValueIndex < _keyPropertyValues.Length; keyValueIndex++) { var currentKeyValue = _keyPropertyValues[keyValueIndex]; var otherKeyValue = other._keyPropertyValues[keyValueIndex]; if (!object.Equals(currentKeyValue, otherKeyValue)) { return(false); } } return(true); }
/// <summary> /// Registers a new entity instance for a row in the result set. /// Signal the end of the row in the result set with a call to <see cref="EndResultSetRow"/>. /// </summary> public void RegisterResultSetRowInstance <TEntity>(ref TEntity entity) { EntityInstanceContainer instanceContainer; object genericEntityInstance; bool requiresBinding; if (!_entityInstanceContainers.TryGetValue(typeof(TEntity), out instanceContainer)) { throw new InvalidOperationException($"Type '{typeof(TEntity)}' could not be found in the list of registered instance containers."); } if (entity == null) { // we want to initialize the relationship, reason why for NULL values we'll pretend we haven't seen this instance genericEntityInstance = entity; requiresBinding = true; } else { var entityInstanceIdentity = new RelationshipEntityInstanceBuilderIdentity(instanceContainer.EntityMapping, entity); if (instanceContainer.KnownInstances.TryGetValue(entityInstanceIdentity, out genericEntityInstance)) { entity = (TEntity)genericEntityInstance; requiresBinding = false; } else { genericEntityInstance = entity; instanceContainer.KnownInstances.Add(entityInstanceIdentity, genericEntityInstance); requiresBinding = true; } } var entityInstanceRowDetails = _currentRowEntityInstances[_currentRowParticipatingEntityCount++]; entityInstanceRowDetails.EntityMapping = instanceContainer.EntityMapping; entityInstanceRowDetails.Instance = genericEntityInstance; entityInstanceRowDetails.RequiresBinding = requiresBinding; }