views:

494

answers:

1

What is the best way to avoid SQL injection on MSSQL Server from C# code using Linq?

Should you use a function to strip of security issues or is it handled by the framework?

+7  A: 

Errr, you cant SQL inject using LINQ. Behind the scenes LINQ to SQL converts values into a parameterized query.

So yes it is handled by the framework.

Jon Limjap
Technically speaking you can still have SQL injection issues if you use the ExecuteCommand or call stored procedures that use sp_execute and combine string input together without proper encoding.
DamienG