/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void Propagate(InternalEntityEntry entry) { foreach (var property in FindPropagatingProperties(entry)) { _keyPropagator.PropagateValue(entry, property); } }
public virtual void Generate(InternalEntityEntry entry) { foreach (var property in entry.EntityType.GetProperties()) { var isForeignKey = property.IsForeignKey(entry.EntityType); if ((property.RequiresValueGenerator || isForeignKey) && property.IsSentinelValue(entry[property])) { if (isForeignKey) { _keyPropagator.PropagateValue(entry, property); } else { var valueGenerator = _valueGeneratorSelector.Select(property, entry.EntityType); Debug.Assert(valueGenerator != null); var generatedValue = valueGenerator.NextSkippingSentinel(property); SetGeneratedValue(entry, property, generatedValue, valueGenerator.GeneratesTemporaryValues); } } } }
public virtual void Generate(InternalEntityEntry entry) { foreach (var property in entry.EntityType.GetProperties()) { var isForeignKey = property.IsForeignKey(entry.EntityType); if ((property.RequiresValueGenerator || isForeignKey) && property.ClrType.IsDefaultValue(entry[property])) { if (isForeignKey) { _keyPropagator.PropagateValue(entry, property); } else { var valueGenerator = _valueGeneratorSelector.Select(property, property.IsKey() ? property.DeclaringEntityType : entry.EntityType); Debug.Assert(valueGenerator != null); SetGeneratedValue(entry, property, valueGenerator.Next(), valueGenerator.GeneratesTemporaryValues); } } } }
private static void PropagateValue(IKeyPropagator keyPropagator, InternalEntityEntry dependentEntry, IProperty property, bool async) { if (async) { keyPropagator.PropagateValueAsync(dependentEntry, property).GetAwaiter().GetResult(); } else { keyPropagator.PropagateValue(dependentEntry, property); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual InternalEntityEntry Propagate(InternalEntityEntry entry) { InternalEntityEntry chosenPrincipal = null; foreach (var property in FindPropagatingProperties(entry)) { var principalEntry = _keyPropagator.PropagateValue(entry, property); if (chosenPrincipal == null) { chosenPrincipal = principalEntry; } } return(chosenPrincipal); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void Generate(InternalEntityEntry entry) { var entityEntry = new EntityEntry(entry); foreach (var propertyTuple in FindProperties(entry)) { var property = propertyTuple.Item1; if (propertyTuple.Item2) { _keyPropagator.PropagateValue(entry, property); } else { var valueGenerator = GetValueGenerator(entry, property); SetGeneratedValue( entry, property, valueGenerator.Next(entityEntry), valueGenerator.GeneratesTemporaryValues); } } }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual InternalEntityEntry?Propagate(InternalEntityEntry entry) { InternalEntityEntry?chosenPrincipal = null; foreach (var property in entry.EntityType.GetForeignKeyProperties()) { if (!entry.HasDefaultValue(property)) { continue; } var principalEntry = _keyPropagator.PropagateValue(entry, property); chosenPrincipal ??= principalEntry; } return(chosenPrincipal); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual InternalEntityEntry Propagate(InternalEntityEntry entry) { InternalEntityEntry chosenPrincipal = null; foreach (var property in FindCandidatePropagatingProperties(entry)) { if (!entry.HasDefaultValue(property)) { continue; } var principalEntry = _keyPropagator.PropagateValue(entry, property); if (chosenPrincipal == null) { chosenPrincipal = principalEntry; } } return(chosenPrincipal); }
private static void PropagateValue(IKeyPropagator keyPropagator, InternalEntityEntry dependentEntry, IProperty property) { keyPropagator.PropagateValue(dependentEntry, property); }