Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

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

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v1.0.6
Package:
Microsoft.EntityFrameworkCore v1.1.6
Package:
Microsoft.EntityFrameworkCore v10.0.0
Package:
Microsoft.EntityFrameworkCore v2.0.3
Package:
Microsoft.EntityFrameworkCore v2.1.11
Package:
Microsoft.EntityFrameworkCore v2.2.6
Package:
Microsoft.EntityFrameworkCore v3.0.0
Package:
Microsoft.EntityFrameworkCore v3.1.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0
Package:
Microsoft.EntityFrameworkCore v9.0.0
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs
Source:
EF.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

References a given property or navigation on an entity or complex type instance. This is useful for shadow state properties, for which no CLR property exists. 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);
public static TProperty Property<TProperty>(object instance, string propertyName);
static member Property : obj * string -> 'Property
static member Property : obj * string -> 'Property
Public Shared Function Property(Of TProperty) (entity As Object, propertyName As String) As TProperty
Public Shared Function Property(Of TProperty) (instance As Object, propertyName As String) As TProperty

Type Parameters

TProperty

The type of the property being referenced.

Parameters

entityinstance
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));

Remarks

Note that this is a static method accessed through the top-level EF static type.

See Using EF.Property in EF Core queries for more information and examples.

Applies to


Feedback

Was this page helpful?