LINQ to SQL vs ADO.Net

后端 未结 6 1941
悲哀的现实
悲哀的现实 2020-12-03 06:51

What\'s the difference between LINQ to SQL and ADO.net ?

6条回答
  •  一向
    一向 (楼主)
    2020-12-03 07:39

    There is a fairly large set of differences between these two technologies that cannot be really covered in a short SO post, but I'll try to cover the highlights

    • In Linq2Sql you write your queries over in memory objects. Under the hood though the code you write is translated to expression trees and is further translated to SQL at runtime where the query is actually run. In ADO.Net you directly build SQL queries which are run against the server.
    • Linq2Sql has direct language support in C# and VB.Net. ADO.Net provides support for string based query which have 0 language support other than just a raw string.
    • The language support in Linq2Sql makes queries type safe. In ADO.Net all query results must be converted to the appropriate type which essentially removes type safety checks.

提交回复
热议问题