LINQ的区别到SQL,LINQ的,类型化数据集,ADO.NET [英] Difference between Linq to Sql, Linq, Typed Datasets, ADO.NET

查看:127
本文介绍了LINQ的区别到SQL,LINQ的,类型化数据集,ADO.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道这一段时间。好像有这么多的方法,现在我不知道什么时候用什么?或者,如果有甚至一个点来学习他们。就像我不知道,如果他们基本上做同样的事情,只是基本上是一个坚持,直到你掌握了它,那么也许看看其他的。

I been wondering about this for a while. It seems like there are so many ways now I don't know when to use what? Or if there is even a point to learn them. Like I don't know if they basically do all the same things and just basically stick with one till you master it then maybe look at other ones.

所以,当我正在一个ASP.NET当然,这是我的计划的一部分。

So when I was taking an ASP.NET course that was part of my program.

我们第一次做类似ADO.NET,我们只是写一切与在code SQL语句。然后我们转移到一个3层架构。这是通过像类和具有回报的东西的数据集进行。

We first did like ADO.NET where we just wrote everything with SQL statements in the code. We then moved onto a 3 tier architecture. This was done by making like classes and having datasets that return stuff.

在SQL写在类。我个人从来没有真正喜欢这种方式,因为我一直觉得很烦人,试图获得报价的权利,只是总不喜欢它。

The SQL was written in the class. I personally never really liked this way since I always found it annoying with trying to get the quotes right and just overall did not like it.

然后我发现在Asp.net网站的3层拱的教程,我真的很喜欢。他们在那里使用类型化的数据集。您的数据集文件添加到您的DAL文件夹,你会通过GUI使表适配器和东西。这样,你会写信给你code在这些GUI,我发现它的完美的解决方案,因为现在我的SQL code是离我的code,我没有担心的报价和所有的东西不是权利或关闭连接之类的东西,再加上它甚至有一个SQL界面生成器!

I then found on the Asp.net site their tutorial of 3 tier arch that I really liked. They where using typed data sets. You add the dataset file to you DAL folder and you would make table adapters and stuff through the GUI. You would then write you code in these GUI, I found it the perfect solution since now my SQL code was away from my code and I did not have to worry about quotes and all that stuff not being right or closing the connections and stuff plus it even had a SQL GUI builder!

然后,我只想让文件中的BLL文件夹,使属性来获取表适配器和写我的业务层逻辑。

Then I would just make file in the BLL folder and make a property to grab the table adapter and write my business layer logic.

我不喜欢的是,因为它是类型化的,如果我的东西,试图返回一些新的行会生气的唯一的事情。

The only thing I did not like was since it was typed if my stuff tried to return some new rows it would get mad.

所以,当我不得不去的表,我通常不得不做出新的表适配器。

So when I had to join tables I usually had to make a new table adapter.

现在似乎有这么多的人。

Now there seems to be so many of them.

  • 的LINQ - >一些人说,将取代ADO.NET有的表示不会
  • 的LINQ to SQL
  • ado.net

我不知道这是所有的人都可能不是。

I am not sure if that is all of them probably not.

在写这篇文章我做了一个快速检查,看看有什么LINQ to SQL的约,看到一些帖子说,MS被杀死它。他们从哪里像2008年,所以我不知道这是不是真的,但我注意到,几乎所有的MVC书使用类似的LINQ to SQL,所以我不认为它是。

Before writing this post I did a quick check to see what linq to sql was about and saw some posts saying that MS was killing it off. They where from like 2008 so I don't know if this is true or not but I noticed that almost all the MVC books use like linq to sql so I don't think it is.

那么,这身价转投一些不同之一,那么类型化数据集?或者,每个用于不同的情况?

So is it worth switching to something a different one then typed datasets? Or are each used for different situations?

推荐答案

LINQ本身只是一个基础技术(语言集成查询)这是烤成C#3.0 - 它的什么做本身与数据库。 LINQ可以用来对付各种各样的事情 - 数据库,XML,内存中的对象,实体框架的实体,Active Directory的 - 你的名字

LINQ by itself is just a base technology ("Language Integrated Query") that's baked into C# 3.0 - it has nothing to do per se with databases. LINQ can be used against a variety of things - databases, XML, objects in memory, Entity Framework entities, Active Directory - you name it.

LINQ到SQL是轻量级的,简单的,MS-SQLServer的唯一技术,让您轻松,并很好地使用SQL Server表作为.NET应用程序真正的对象。这是一个对象 - 关系映射器,使得处理数据库更容易。这是SQL Server只,而微软也不会扩展它更进一步 - 这是用,也是在.NET 4.0中,但不会进一步发展更多的

Linq-To-SQL is the lightweight, straightforward, MS-SQLServer only technology which allows you to use SQL Server tables easily and nicely as real objects in your .NET application. It's a "Object-relational mapper" that makes dealing with databases easier. It's SQL Server only, and Microsoft will not extend it much further - it's available, also in .NET 4.0, but won't be further developed any more.

ADO.NET是在.NET中的基础数据访问技术 - 它允许您访问各种各样的数据存储,关系型和非关系的。这是非常基本的技术 - 你处理你的数据在一个非常低的水平,原始的方式

ADO.NET is the base data access technology in .NET - it gives you access to a wide variety of data stores, relational and non-relational. It's the very basic technology - you deal with your data in a very low-level, raw manner.

在最重要的是,你有ADO.NET数据集,这是一个有点像LINQ到SQL,因为它们使比较容易处理的数据库。相反,LINQ到SQL,你不能从你的域模型在.NET code处理您的对象,而是你处理面向数据库的行和列就像他们在数据库中存在。这是一个什么样的数据库中的一个更直接的重新presentation,它是在一个较低的水平,这是非常紧耦合到您的数据库布局,它不是好和容易LINQ到SQL对象使用 - 你对付低级的行和列的值。

On top of that, you have the ADO.NET datasets, which are a bit like Linq-to-SQL in that they make it somewhat easier to deal with databases. Contrary to Linq-to-SQL, you're not dealing with your objects from your domain model in your .NET code, but instead you're dealing with the database-oriented rows and columns just like they exist in the database. It's a more direct representation of what's in the database, it's on a lower level, it's very tightly coupled to your database layout, and it's not as "nice" and easy to use as Linq-To-SQL objects - you deal with lowlevel rows and columns and their values.

如果你有选择的权利,并且不需要任何东西,但SQL Server中,我会强烈建议检查出LINQ到SQL - 从原始数据库表好,易于映射使用.NET对象真的让你的生活轻松许多!

If you have the choice right now, and don't need anything but SQL Server, I would highly recommend checking out Linq-to-SQL - the mapping from the raw database tables to nice and easy to use .NET objects really makes your life a whole lot easier!

马克·

这篇关于LINQ的区别到SQL,LINQ的,类型化数据集,ADO.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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