QueryTypeBuilder Class

Definition

Provides a simple API for configuring a query type.

Instances of this class are returned from methods when using the ModelBuilder API and it is not designed to be directly constructed in your application code.

public class QueryTypeBuilder : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.IMutableModel>, Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder>
type QueryTypeBuilder = class
    interface IInfrastructure<IMutableModel>
    interface IInfrastructure<InternalEntityTypeBuilder>
Public Class QueryTypeBuilder
Implements IInfrastructure(Of IMutableModel), IInfrastructure(Of InternalEntityTypeBuilder)
Inheritance
QueryTypeBuilder
Derived
Implements
IInfrastructure<IMutableModel> IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder>

Constructors

QueryTypeBuilder(InternalEntityTypeBuilder)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

Properties

Metadata

The query type being configured.

Methods

HasAnnotation(String, Object)

Adds or updates an annotation on the query type. If an annotation with the key specified in annotation already exists its value will be updated.

HasBaseType(String)

Sets the base type of this query type in an inheritance hierarchy.

HasBaseType(Type)

Sets the base type of this query type in an inheritance hierarchy.

HasOne(String, String)

Configures a relationship where this query type has a reference that points to a single instance of the other type in the relationship.

Note that calling this method with no parameters will explicitly configure this side of the relationship to use no navigation property, even if such a property exists on the entity type. If the navigation property is to be used, then it must be specified.

After calling this method, you should chain a call to WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

HasOne(Type, String)

Configures a relationship where this query type has a reference that points to a single instance of the other type in the relationship.

After calling this method, you should chain a call to WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

HasQueryFilter(LambdaExpression)

Specifies a LINQ predicate expression that will automatically be applied to any queries targeting this query type.

Ignore(String)

Excludes the given property from the query type. This method is typically used to remove properties from the query type that were added by convention.

Property(String)

Returns an object that can be used to configure a property of the query type. If no property with the given name exists, then a new property will be added.

When adding a new property with this overload the property name must match the name of a CLR property or field on the query type. This overload cannot be used to add a new shadow state property.

Property(Type, String)

Returns an object that can be used to configure a property of the query type. If no property with the given name exists, then a new property will be added.

When adding a new property, if a property with the same name exists in the query type class then it will be added to the model. If no property exists in the query type class, then a new shadow state property will be added. A shadow state property is one that does not have a corresponding property in the query type class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the query type class.

Property<TProperty>(String)

Returns an object that can be used to configure a property of the query type. If no property with the given name exists, then a new property will be added.

When adding a new property, if a property with the same name exists in the query type class then it will be added to the model. If no property exists in the query type class, then a new shadow state property will be added. A shadow state property is one that does not have a corresponding property in the query type class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the query type class.

UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for all properties of this query type.

By default, the backing field, if one is found by convention or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. Calling this method will change that behavior for all properties of this query type as described in the PropertyAccessMode enum.

Calling this method overrides for all properties of this query type any access mode that was set on the model.

Explicit Interface Implementations

IInfrastructure<IMutableModel>.Instance

The model that the query type belongs to.

IInfrastructure<InternalEntityTypeBuilder>.Instance

Gets the internal builder being used to configure the query type.

Extension Methods

GetInfrastructure<T>(IInfrastructure<T>)

Gets the value from a property that is being hidden using IInfrastructure<T>.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

HasDiscriminator(QueryTypeBuilder)

Configures the discriminator column used to identify which query type each row in a table represents when an inheritance hierarchy is mapped to a single table in a relational database.

HasDiscriminator(QueryTypeBuilder, String, Type)

Configures the discriminator column used to identify which query type each row in a table represents when an inheritance hierarchy is mapped to a single table in a relational database.

HasDiscriminator<TDiscriminator>(QueryTypeBuilder, String)

Configures the discriminator column used to identify which query type each row in a table represents when an inheritance hierarchy is mapped to a single table in a relational database.

ToView(QueryTypeBuilder, String)

Configures the view or table that the view maps to when targeting a relational database.

ToView(QueryTypeBuilder, String, String)

Configures the view or table that the view maps to when targeting a relational database.

Applies to