jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL Injection question on below Implementation

keerthirajap opened this issue · comments

Question

Will below implementations cause SQL Injection issues. Can you please advice on using inline queries and passing parameters "SELECT * FROM Beer WHERE type = @type".

Are both implementations are safe to use?

Steps to reproduce

Implementation 1


public interface IBeerRepository
{	
	[Sql("SELECT * FROM Beer WHERE type = @type")]
	IList<Beer> GetBeerByType(string type);
}

Implementation 2

IList<Beer> beer = Database.Connection().QuerySql<Beer>(
	"SELECT * FROM Beer WHERE Name = @Name",
	new { Name = "IPA" });
  • Dotnet version: [netcore2,]
  • Database: [SQL Server]
  • Library version: [6.2.3]