ValueGenerator ValueGenerator Class

Definition

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

public abstract class ValueGenerator
Public MustInherit Class ValueGenerator
Inheritance
System.ObjectSystem.Object
ValueGeneratorValueGenerator

Inherited Members

System.Object

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

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
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
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<System.Object> System.Threading.Tasks.Task(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
cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<System.Object> System.Threading.Tasks.Task(Of System.Object)

The generated value.