RelationalDbContextOptionsBuilder<TBuilder,TExtension>.TranslateParameterizedCollectionsToConstants Method
Definition
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.
Caution
Use UseParameterizedCollectionMode instead.
Configures the context to translate parameterized collections to inline constants.
[System.Obsolete("Use UseParameterizedCollectionMode instead.")]
public virtual TBuilder TranslateParameterizedCollectionsToConstants();
public virtual TBuilder TranslateParameterizedCollectionsToConstants();
[<System.Obsolete("Use UseParameterizedCollectionMode instead.")>]
abstract member TranslateParameterizedCollectionsToConstants : unit -> 'Builder
override this.TranslateParameterizedCollectionsToConstants : unit -> 'Builder
abstract member TranslateParameterizedCollectionsToConstants : unit -> 'Builder
override this.TranslateParameterizedCollectionsToConstants : unit -> 'Builder
Public Overridable Function TranslateParameterizedCollectionsToConstants () As TBuilder
Returns
- Attributes
Remarks
When a LINQ query contains a parameterized collection, by default EF Core translates as a multiple SQL parameters, if possible. For example, on SQL Server, the LINQ query Where(b => ids.Contains(b.Id) is translated to WHERE [b].[Id] IN (@ids1, @ids2, @ids3).
TranslateParameterizedCollectionsToConstants() instructs EF to translate the collection to a set of constants: WHERE [b].[Id] IN (1, 2, 3). This can produce better query plans for certain query types, but can also lead to query plan bloat.
Note that it's possible to cause EF to translate a specific collection in a specific query to constants by wrapping the parameterized collection in Constant<T>(T): Where(b => EF.Constant(ids).Contains(b.Id). This overrides the default.