Entity Framework Core SQL LINQ
There are some static methods under the namespace:
"Microsoft.EntityFrameworkCore", that can provides CLR methods that
get translated to database functions when used in LINQ to queries and Lambda
Extension.
For example, a query with LIKE expression.
var entities = myDbContext.MyEntity.Where(x => EF.Functions.Like(x.Name, "%ack%"));
Or
var entities = from x in myDbContext.MyEntity
where EF.Functions.Like(x.Name, "%ack%")
select x;
In Entity
Framework, we can use the static method: SqlMethods to
do the same thing as EF.Functions in
EF Core.
For more
reference on the mappings between the query expression and SQL, see Npgsql- Entity Framework CoreMapping and translationTranslations.
沒有留言:
張貼留言