Do you know when to use raw sql?

Last updated by Brook Jeynes [SSW] 8 months ago.See history

Raw SQL comes with risks but sometimes it is the best solution.

Using raw SQL involves taking care of SQL injection and other risks, however there are a number of situations where it may be the best solution.

The most obvious is a SQL UPDATE statement which updates a large number of rows.

await context.Database.ExecuteSqlInterpolatedAsync($"UPDATE Employees SET Active = {activeState}", ct);

Good example - Updating a large number of rows quickly with SQL

We open source. Powered by GitHub