EF.Property<TProperty>(Object, String) Method

Definition

Addresses a given property on an entity instance. This is useful when you want to reference a shadow state property in a LINQ query. Currently this method can only be used in LINQ queries and can not be used to access the value assigned to a property in other scenarios.

public static TProperty Property<TProperty> (object entity, string propertyName);
static member Property : obj * string -> 'Property
Public Shared Function Property(Of TProperty) (entity As Object, propertyName As String) As TProperty

Type Parameters

TProperty

The type of the property being referenced.

Parameters

entity
Object

The entity to access the property on.

propertyName
String

The name of the property.

Returns

TProperty

The value assigned to the property.

Examples

The following code performs a filter using the a LastUpdated shadow state property.

var blogs = context.Blogs
    .Where(b => EF.Property<DateTime>(b, "LastUpdated") > DateTime.Now.AddDays(-5));

Applies to