输入banner图图片脚本导航/分类

EntityFramework Core入门教程-11-使用原生的SQL

leagues = context.Leagues .FromSqlRaw("select * from efcoredemo.Leagues") .ToList();

原生sql查询要求:
1 必须返回Enitty类型的所有属性,即必须使用 Select * …
2 字段名和Entity属性名配置
3 无法包含关联的数据
4 只能查询已知的Entity

二、执行非查询类SQL

一、执行非字符串插值字符串

Context.Database.ExecuteSQLRaw()
Context.Database.ExecuteSQLRawAsync();

二、执行字符串插值字符串

Context.Database.ExecuteSQLInterpolated()
Context.Database.ExecuteSQLInterpolatedAsync()

EntityFramework Core入门教程-11-使用原生的SQL

标签:语法   cti   path   RKE   href   XML   line   lint   sdn