mhmd-azeez / SqlValidator

A roslyn analyzer to validate your SQL queries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SqlValidator

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

How to use

  1. Set SqlAnalyzer_ConnectionString to a proper connection string.
  2. 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
    }
}
  1. Notice how it tells you that you have to declare @prsonName before using it.
  2. Change @prsonName to @personName and now the warning goes away!

About

A roslyn analyzer to validate your SQL queries


Languages

Language:C# 74.3%Language:PowerShell 25.7%