Note

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

Access to this page requires authorization. You can try .

RelationalQueryableExtensions.FromSqlInterpolated<TEntity> Method

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.Relational.dll
Package:
Microsoft.EntityFrameworkCore.Relational v10.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v3.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v3.1.0
Package:
Microsoft.EntityFrameworkCore.Relational v5.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v6.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v7.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v8.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v9.0.0
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.cs
Source:
RelationalQueryableExtensions.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.

Creates a LINQ query based on an interpolated string representing a SQL query.

public static System.Linq.IQueryable<TEntity> FromSqlInterpolated<TEntity>(this Microsoft.EntityFrameworkCore.DbSet<TEntity> source, FormattableString sql) where TEntity : class;
static member FromSqlInterpolated : Microsoft.EntityFrameworkCore.DbSet<'Entity (requires 'Entity : null)> * FormattableString -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function FromSqlInterpolated(Of TEntity As Class) (source As DbSet(Of TEntity), sql As FormattableString) As IQueryable(Of TEntity)

Type Parameters

TEntity

The type of the elements of source.

Parameters

source
DbSet<TEntity>

An IQueryable<T> to use as the base of the interpolated string SQL query (typically a DbSet<TEntity>).

sql
FormattableString

The interpolated string representing a SQL query with parameters.

Returns

IQueryable<TEntity>

An IQueryable<T> representing the interpolated string SQL query.

Remarks

If the database provider supports composing on the supplied SQL, you can compose on top of the raw SQL query using LINQ operators.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include interpolated parameter place holders in the SQL query string. Any interpolated parameter values you supply will automatically be converted to a DbParameter.

See Executing raw SQL commands with EF Core for more information and examples.

Applies to


Feedback

Was this page helpful?