Will using LINQ to SQL help prevent SQL injection

前端 未结 3 1708
梦谈多话
梦谈多话 2020-11-29 01:31

I\'m setting up a public site and the first thing on my mind is SQL injection. I have some text fields I\'m saving and am using linq to update/write to the database. Am I sa

相关标签:
3条回答
  • 2020-11-29 01:48

    You're good to go. Linq does parameterize the data it sends to the database.

    Use the Log property to check out what's happening: dc.Log = Console.Out;

    0 讨论(0)
  • 2020-11-29 02:08

    It should because the SQL emitted uses named parameters which cannot be exploited to execute arbitrary SQL.

    0 讨论(0)
  • 2020-11-29 02:12

    Yes, LINQ will help stop SQL injection.

    LINQ to SQL passes all data to the database via SQL parameters. So, although the SQL query is composed dynamically, the values are substitued server side through parameters safeguarding against the most common cause of SQL injection attacks.

    Also, see Eliminate SQL Injection Attacks Painlessly with LINQ for some info.

    0 讨论(0)
提交回复
热议问题