what is the difference between LINQ and开发者_高级运维 ADO.net
Linq is a language feature (Language INtegrated Query) that allows for querying of objects. It is often conflated with Linq to Sql, which is a series of extension methods and other code that allows querying of a Sql Server database using Linq statements.
You can write a Linq provider to query any kind of datasource, for example, there is a Linq to Amazon provider that allows you to retrieve results from Amazon's public API.
ADO.Net is series of technologies for retrieving data, I suggest starting here: http://en.wikipedia.org/wiki/ADO.NET
I think you probably mean LINQ-to-SQL. ADO.NET is the bare bones of talking to a Database, so you need to set up the DataTables, DataReaders, etc. yourself. This includes iterating through our tables, setting up your connections, transactions, etc.
LINQ-to-SQL is an ORM (Object Relationship Mapper) which allows you to view your data as business objects, instead of collections of data in DataTables. LINQ-to-SQL works with ADO.NET under the hood. Much easier!
LINQ is the expression syntax used by LINQ-to-SQL to query tables, eg
ClientSet.Where(q=>q.ID==1).First();
LINQ to SQL actually stands for LINQ to 'databases that use SQL' or in other words LINQ for the relational data model. LINQ to Entities means LINQ for the Entity-Data-Model which is a kind of a relational++ model.
More info:
http://blogs.microsoft.co.il/blogs/gilf/archive/2008/04/20/linq-to-sql-vs-entity-framework.aspx
ADO.NET
- It is a part of .NET Framework since .NET Framework 1.0
- SqlConnection/OleDbConnection is used for database connectivity.
- Difficult to debug and cause syntax errors at run-time.
- It has full type checking at run-time and not IntelliSense support in Visual Studio, since it used the T-SQL to query the database.
LINQ
- It is a part of .NET Framework since .NET Framework 3.5
- We can use context for database connectivity.
- Easy to debug and cause syntax errors at compile-time.
- It has full type checking at compile-time and IntelliSense support in Visual Studio, since it used the .NET Framework languages like C# and VB.
精彩评论