ValueGenerator ValueGenerator Class

Generates values for properties when an entity is added to a context.

Syntax

Declaration

public abstract class ValueGeneratorPublic MustInherit Class ValueGenerator

Inheritance Hierarchy

  • System.Object
    System.Object
  • ValueGenerator
    ValueGenerator

Inherited Members

ToString(),
ToString(),
Equals(Object),
Equals(Object),
Equals(Object, Object),
Equals(Object, Object),
ReferenceEquals(Object, Object),
ReferenceEquals(Object, Object),
GetHashCode(),
GetHashCode(),
GetType(),
GetType(),
MemberwiseClone()
MemberwiseClone()

Properties summary

Gets a value indicating whether the values generated are temporary (i.e they should be replaced by database generated values when the entity is saved) or are permanent (i.e. the generated values should be saved to the database).

An example of temporary value generation is generating negative numbers for an integer primary key that are then replaced by positive numbers generated by the database when the entity is saved. An example of permanent value generation are client-generated values for a System.Guid primary key which are saved to the database.

Methods summary

Gets a value to be assigned to a property.

Gets a value to be assigned to a property.

Template method to be overridden by implementations to perform value generation.

Template method to be overridden by implementations to perform value generation.

Properties

  • GeneratesTemporaryValues
    GeneratesTemporaryValues

    Gets a value indicating whether the values generated are temporary (i.e they should be replaced by database generated values when the entity is saved) or are permanent (i.e. the generated values should be saved to the database).

    An example of temporary value generation is generating negative numbers for an integer primary key that are then replaced by positive numbers generated by the database when the entity is saved. An example of permanent value generation are client-generated values for a System.Guid primary key which are saved to the database.

    public abstract bool GeneratesTemporaryValues { get; }Public MustOverride ReadOnly Property GeneratesTemporaryValues As Boolean

    Property Value

    • System.Boolean
      System.Boolean

Methods

  • Next(EntityEntry)
    Next(EntityEntry)

    Gets a value to be assigned to a property.

    public virtual object Next(EntityEntry entry)Public Overridable Function Next(entry As EntityEntry) As Object

    Parameters

    Returns

    • System.Object
      System.Object

      The value to be assigned to a property.

  • NextAsync(EntityEntry, CancellationToken)
    NextAsync(EntityEntry, CancellationToken)

    Gets a value to be assigned to a property.

    public virtual Task<object> NextAsync(EntityEntry entry, CancellationToken cancellationToken = null)Public Overridable Function NextAsync(entry As EntityEntry, cancellationToken As CancellationToken = Nothing) As Task(Of Object)

    Parameters

    • entry
    • cancellationToken
      System.Threading.CancellationToken
      System.Threading.CancellationToken

    Returns

    • System.Threading.Tasks.Task<TResult><System.Object>
      System.Threading.Tasks.Task<TResult>(Of System.Object)

      The value to be assigned to a property.

  • NextValue(EntityEntry)
    NextValue(EntityEntry)

    Template method to be overridden by implementations to perform value generation.

    protected abstract object NextValue(EntityEntry entry)Protected MustOverride Function NextValue(entry As EntityEntry) As Object

    Parameters

    Returns

    • System.Object
      System.Object

      The generated value.

  • NextValueAsync(EntityEntry, CancellationToken)
    NextValueAsync(EntityEntry, CancellationToken)

    Template method to be overridden by implementations to perform value generation.

    protected virtual Task<object> NextValueAsync(EntityEntry entry, CancellationToken cancellationToken = null)Protected Overridable Function NextValueAsync(entry As EntityEntry, cancellationToken As CancellationToken = Nothing) As Task(Of Object)

    Parameters

    • entry
    • cancellationToken
      System.Threading.CancellationToken
      System.Threading.CancellationToken

    Returns

    • System.Threading.Tasks.Task<TResult><System.Object>
      System.Threading.Tasks.Task<TResult>(Of System.Object)

      The generated value.

Details

Assembly

Microsoft.EntityFrameworkCore.dll