A Roslyn-based analyzer for SQL related stuff in .NET
Noncompliant Code Example:
Query<Thing>("select * from Thing where Name = @Name", new { Name = abcde });
Compliant Solution:
Query<Thing>("select * from Thing where Name = @Name", new {Name = new DbString { Value = "abcde", IsFixedLength = true, Length = 10, IsAnsi = true }});
https://github.com/StackExchange/Dapper/blob/master/Readme.md#ansi-strings-and-varchar
Noncompliant Code Example:
var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Id = guid });
Compliant Solution:
var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });
Noncompliant Code Example:
var dog = connection.Query<Dog>("select * from dogs").Single();
Compliant Solution:
var dog = connection.QuerySingle<Dog>("select * from dogs");