A roslyn analyzer to validate your SQL queries
Note: This project is just a proof of concept. It needs a lot more work in order to work properly.
Demo: https://youtu.be/yrTwGXqbsTs and https://youtu.be/zLTDqnNY2K4
- Set
SqlAnalyzer_ConnectionString
to a proper connection string. - Write some code:
var connectionString = "...";
using (var connection = new SqlConnection(connectionString))
{
await connection.OpenAsync();
using (var command = new SqlCommand(@"SELECT * FROM PEOPLE WHERE Name LIKE @prsonName", connection))
{
command.Parameters.AddWithValue("personName", "%Muhammad%");
// rest of the code
}
}
- Notice how it tells you that you have to declare
@prsonName
before using it. - Change
@prsonName
to@personName
and now the warning goes away!