RelationalQueryableExtensions.AsSplitQuery<TEntity> Method

Definition

Returns a new query which is configured to load the collections in the query results through separate database queries.

This behavior can significantly improve performance when the query loads multiple collections. However, since separate queries are used, this can result in inconsistent results when concurrent updates occur. Serializable or snapshot transactions can be used to mitigate this and achieve consistency with split queries, but that may bring other performance costs and behavioral difference.

The default query splitting behavior for queries can be controlled by UseQuerySplittingBehavior(QuerySplittingBehavior).

public static System.Linq.IQueryable<TEntity> AsSplitQuery<TEntity> (this System.Linq.IQueryable<TEntity> source) where TEntity : class;
static member AsSplitQuery : System.Linq.IQueryable<'Entity (requires 'Entity : null)> -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function AsSplitQuery(Of TEntity As Class) (source As IQueryable(Of TEntity)) As IQueryable(Of TEntity)

Type Parameters

TEntity

The type of entity being queried.

Parameters

source
IQueryable<TEntity>

The source query.

Returns

IQueryable<TEntity>

A new query where collections will be loaded through separate database queries.

Remarks

See EF Core split queries for more information.

Applies to