RelationalQueryableExtensions.FromSqlInterpolated<TEntity> 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
Use FromSql() instead. This method is obsolete and will be removed in a future release.
基于表示 SQL 查询的内插字符串创建 LINQ 查询。
public static System.Linq.IQueryable<TEntity> FromSqlInterpolated<TEntity>(this Microsoft.EntityFrameworkCore.DbSet<TEntity> source, FormattableString sql) where TEntity : class;
[System.Obsolete("Use FromSql() instead. This method is obsolete and will be removed in a future release.")]
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)
[<System.Obsolete("Use FromSql() instead. This method is obsolete and will be removed in a future release.")>]
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)
类型参数
- TEntity
的元素 source的类型。
参数
- source
- DbSet<TEntity>
IQueryable<T>用作内插字符串 SQL 查询的基数(通常是一个DbSet<TEntity>)。
表示具有参数的 SQL 查询的内插字符串。
返回
表示 IQueryable<T> 内插字符串 SQL 查询。
- 特性
注解
如果数据库提供程序支持在提供的 SQL 上进行撰写,则可以使用 LINQ 运算符在原始 SQL 查询的基础上进行撰写。
与接受 SQL 的任何 API 一样,必须参数化任何用户输入以防止 SQL 注入攻击。 可以在 SQL 查询字符串中包含内插参数位置持有者。 你提供的任何内插参数值将自动转换为一个 DbParameter。
有关详细信息和示例,请参阅 使用 EF Core 执行原始 SQL 命令 。