Developer bit

Take control of query parameterization in EF 9

Take control of query parameterization in EF 9

In Entity Framework 9 we will have more control on how parameters and constants are used within the generated SQL queries. Using the two new methods EF.Parameter and EF.Constant you can decide on how the query parameters are generated, which is useful when you want to force or prevent query parameterization.

This feature makes it easier to manage the query plans that are created, and thus can help to improve the performance of your queries and application.

var blogs = await ctx.Set<Blog>()
.Where(blog => blog.Title.Contains(EF.Parameter("entity framework")))
.ToListAsync();
var blog = await ctx.Set<Blog>()
.Where(blog => blog.Id == EF.Constant(id))
.SingleAsync();

For more information, see the "What's New in EF Core 9" documentation.

Enjoying the blog?

Support my work

If you enjoyed this post and found it useful, consider supporting my work. It helps me keep creating and sharing content like this. Thank you!