Class EFCoreSeltzrOptionsBuilderExtensions
Extension methods for the SeltzrOptionsBuilder<TModel, TUser> class specific to Entity Framework
Namespace: Seltzr.Extensions
Assembly: Seltzr.EntityFrameworkCore.dll
Syntax
C#
public static class EFCoreSeltzrOptionsBuilderExtensions
Methods
|
Improve this Doc
View Source
EagerLoad<TModel, TUser>(SeltzrOptionsBuilder<TModel, TUser>, Expression<Func<TModel, Object>>[])
Eagerly loads the given properties before returning the model
C#
public static SeltzrOptionsBuilder<TModel, TUser> EagerLoad<TModel, TUser>(this SeltzrOptionsBuilder<TModel, TUser> builder, params Expression<Func<TModel, object>>[] properties)
where TModel : class where TUser : class
Parameters
builder
SeltzrOptionsBuilder<TModel, TUser>
The options builder to perform the operation on
properties
Expression<Func<TModel, Object>>[]
The properties to eagerly load
Returns
SeltzrOptionsBuilder<TModel, TUser>
This SeltzrOptionsBuilder<TModel, TUser> object, for chaining
Type Parameters
TModel
The model type that the API is being built for
TUser
The type of authenticated user context
Remarks
This method internally calls Entity Framework's Include
method. However, calls to ThenInclude
are unsupported. Instead, use Filter(Func<IQueryable<TModel>, IQueryable<TModel>>) to include multiple levels of navigation properties.
Examples
Include navigation properties in the API response:
C#
options.EagerLoad(e => e.Project, e => e.Profile);
Include all projects and tasks in the API response:
C#
options.Filter(d => d.Include(e => e.Project).ThenInclude(p => p.Tasks));