https://github.com/mhmd-azeez/sqlvalidator
A roslyn analyzer to validate your SQL queries
https://github.com/mhmd-azeez/sqlvalidator
roslyn-analyzer sql-queries
Last synced: 6 months ago
JSON representation
A roslyn analyzer to validate your SQL queries
- Host: GitHub
- URL: https://github.com/mhmd-azeez/sqlvalidator
- Owner: mhmd-azeez
- Created: 2020-03-01T18:16:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T20:03:13.000Z (over 1 year ago)
- Last Synced: 2025-04-06T22:43:51.570Z (6 months ago)
- Topics: roslyn-analyzer, sql-queries
- Language: C#
- Size: 27.3 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SqlValidator
A roslyn analyzer to validate your SQL queriesNote: 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:
```csharp
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
}
}
```
3. Notice how it tells you that you have to declare `@prsonName` before using it.
4. Change `@prsonName` to `@personName` and now the warning goes away!