linq to sql从中受益吗? [英] linq to sql the benefit from it ?

查看:61
本文介绍了linq to sql从中受益吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想知道使用linq到sql有什么好处?

最好是使用linq to sql ot将类用于插入更新删除并选择???


提前thanx

Hi all just I want to know what''s the benefit from using linq to sql ??

is it will be better to use linq to sql ot to use the classes for insert update delete and select ???


thanx in advance

推荐答案

除了Collin撰写的内容外,还请参见以下内容: 您会得到什么:
-您将查询语言集成到.net语言中.好吧,这根本不是什么新鲜事物,但是现在在OOP中.
-您具有强类型化的数据集和强类型化的结果,因此您具有IntelliSense
-您在数据库上方有一层,因此可以分离数据访问,并在需要时进行更改
-从理论上讲,您不需要了解SQL
-您不需要处理参数,因此可以(或多或少)忘记SQLi
-易于开发和维护
你松了什么:
-完全控制正在运行的查询的能力.由于查询优化器是针对一般情况而构建的,因此即使您必须控制查询计划,您也可能会有特殊情况
-您失去了服务器端用户功能(UDF)的功能
-您实际上可以忘记除了数据本身之外DBMS中的内容

但是,看起来EntityFramework是未来.那里还有LINQ.

更笼统地说:如果您需要深入控制语句的构建和运行方式,请不要使用这些功能.但是在大多数情况下,LINQ将是一个很好的方法.
Besides what Collin wrote see followings:
What you gain:
- You have a query language integrated in a .net language. Well, this is not new at all, but now in OOP.
- You have strongly typed datasets and strongly typed results, thus you have IntelliSense
- You have a layer above the db, thus you can separate data access, and change if needed
- You dont need to know SQL (theoretically)
- You dont need to deal with parameters, and thus you can (more or less) forget about SQLi
- Ease in development and maintenance
What you loose:
- The power of full control over your running query. As query optimizers are built for general cases, you might have special cases when you have to control even the query plan
- You loos the power of serverside user functions (UDF)
- You can actually forget what''s in the DBMS aside from the data itself

But, it look like EntityFramework is the future. There you also have LINQ.

More generally: if you need deep control ower how statements are built and ran, don''t use these features. But in most cases LINQ will be a good approach.


实际上并不建议这样做.

通常,对于插入,更新,删除等,应使用存储过程.原因是,如果更改了表,则可以更新SPROC,而无需重新分发新代码.


我已经看到了用于干净的SPROC调用的LINQ to SQL,但实际上没有必要.它的确允许快速构建代码等.但是,编写从代码中调用SPROC所需的几行代码并不需要花费那么长时间.不过,这里有好处(我知道的唯一好处).
一个用于访问数据库的简单GUI(拖放所需的内容).如果您只是在测试和尝试学习该技术,那将非常有用.但是对于将要上线的实际系统,我不建议这样做,因为维护会在任何更改请求出现后杀死您.

通常,LINQ to SQL已经被认为已经存在一段时间了.
It is not recomended actually.

In general for inserts updates deletes etc. you should use Stored Procedures. The reason being is that if the Table(s) change you then update the SPROC and there is no need to redistribute new code.


I have seen LINQ to SQL used for clean SPROC calls but really there is no need. It does allow for a quick code building etc. but it does not take that long to write the few lines needed to call SPROCs from code. There in lies the benefit though (the only benefit that I know of).
A simple GUI to access DBs (drag and drop what you need). If you are just testing and playing around trying to learn the technology it is quite useful. But for an actual system that will go live I would not recomend as the maintanence will kill you after any change requests come in.

In general LINQ to SQL has been considered dead for some time now.


这篇关于linq to sql从中受益吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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