ADO.NET 或 Linq to SQL? [英] ADO.NET or Linq to SQL?

查看:21
本文介绍了ADO.NET 或 Linq to SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个论坛,它有 4 个表:用户、主题、评论、主题.

I am building a forum, and it has got 4 tables: Users, Threads, Comments, Topics.

我建立了连接和页面.我开始使用 ADO.net 方式插入数据和选择数据.但后来我发现要进行更复杂的操作,我需要了解 SQL.所以我在寻找另一种方法,我发现我可以打开 Visual Studio 2010,将 Linq 添加到生成对象关系设计器的 SQL 文件中.我读到了如何编写代码,我发现我只需要使用带有 DataContext 对象的 using 语句和一个简单的代码来更新、添加、删除表中的行.

I established the connection and the pages.. I started using the ADO.net way to insert data and select data..but then I found that to make more complex manipulations i need to know SQL. So I was looking for another way, and I found that I can open Visual Studio 2010, add Linq to SQL file that produced object relational designer. I read about how to write code, and I saw that I simply need to use a using statement with DataContext object with a simple code to update, add, delete rows in the tables.

我想知道,使用一种查询方式比另一种查询方式有什么优势?

I wanted to know, what are the advantages of using one way of querying over another?

推荐答案

LINQ to SQL 是 ADO.NET 技术系列的一部分.它基于 ADO.NET 提供程序模型提供的服务.因此,您可以将 LINQ to SQL 代码与现有的 ADO.NET 应用程序混合,并将当前的 ADO.NET 解决方案迁移到 LINQ to SQL.下图提供了关系的高级视图.

LINQ to SQL is part of the ADO.NET family of technologies. It is based on services provided by the ADO.NET provider model. You can therefore mix LINQ to SQL code with existing ADO.NET applications and migrate current ADO.NET solutions to LINQ to SQL. The following illustration provides a high-level view of the relationship.

请参阅以下内容:

ADO.NET 和 LINQ to SQL

优势&LINQ的缺点

LINQ 的性能通过普通存储过程转换为 SQL

LINQ-to-SQL 和存储程序

这篇关于ADO.NET 或 Linq to SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆