CosmosQueryableExtensions.FromSql<TEntity> 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.
Creates a LINQ query based on an interpolated string representing a SQL query.
public static System.Linq.IQueryable<TEntity> FromSql<TEntity> (this Microsoft.EntityFrameworkCore.DbSet<TEntity> source, FormattableString sql) where TEntity : class;
static member FromSql : Microsoft.EntityFrameworkCore.DbSet<'Entity (requires 'Entity : null)> * FormattableString -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function FromSql(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>).
The interpolated string representing a SQL query with parameters.
Returns
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 Cosmos parameter.
See Executing raw SQL commands with EF Core for more information and examples.
Applies to
Entity Framework