优点和LINQ的缺点(语言集成查询) [英] Pros and Cons of LINQ (Language-Integrated Query)

查看:319
本文介绍了优点和LINQ的缺点(语言集成查询)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 什么是LINQ(语言集成查询)?的利弊
  • 什么是在使用LINQ?最好的和最坏的情况下
  • 如何让你受益或使用LINQ没有受益?
  • 在哪些数据源中受益最少,充分利用LINQ?

推荐答案

我的LINQ一个庞大的粉丝 - 尽管它需要保持的角度来看,而不应被视为灵丹妙药

I'm a massive fan of LINQ - although it needs to be kept in perspective, and not treated as a silver bullet.

优点:

  • 在声明的方式让查询更容易理解和更紧凑的
  • 可扩展性和EX pression树木允许多个来源大多是一致的查询
  • 即使在过程查询可以在方面比其他的LINQ到对象来实现 - 比如并行LINQ和我自己的推LINQ框架。非常灵活。
  • 惊人的用于在线查询,其中最简单的方法有助于理解
  • 大,以便能够避免串等SQL
  • 在默认情况下,为运营商提供广泛,和其他人可以很容易地对LINQ添加到对象
  • 在推出主要是为LINQ的语言功能广泛适用在其他地方(耶的lambda表达式)
  • Declarative approach makes queries easier to understand and more compact
  • Extensibility and expression trees allow mostly consistent querying of multiple sources
  • Even in-process queries can be implemented in ways other than LINQ to Objects - e.g. Parallel LINQ and my own Push LINQ framework. Very flexible.
  • Fabulously useful for in-process queries, where it's easiest to understand
  • Great to be able to avoid SQL in strings etc
  • Wide range of operators provided by default, and others can easily be added for LINQ to Objects
  • Language features introduced primarily for LINQ are widely applicable elsewhere (yay for lambdas)

缺点:

  • 在查询前pressions不被理解不够好,而被过度使用。通常,简单的方法调用更短和更简单。
  • 在供应商之间不可避免的矛盾 - 阻抗不匹配仍然是present,这是合理的,但需要理解
  • 在生活中总会有一些东西,你可以在SQL做,但不是在LINQ
  • 在不理解这是怎么回事,它很容易写的很低效code
  • 这是很难写一个LINQ提供程序。这也许是不可避免的,但来自微软的更多指导,将AP preciated。
  • 这是考虑对于大多数开发人员的数据访问的新方法,并需要时间理解渗透
  • 在未具体LINQ但是涉及到它 - 扩展方法被发现在C#中的方法是粒度不够
  • 在一些运营商失踪,特别是排序依据等同的东西比其他排序 - 例如找到与属性的最大值的项目
  • 延迟执行和流媒体知之甚少(但改善)
  • 在调试可能会非常棘手,由于延迟执行和流
  • Query expressions aren't understood well enough, and are overused. Often simple method invocation is shorter and simpler.
  • Inevitable inconsistencies between provider - impedance mismatch is still present, which is reasonable but needs to be understood
  • There will always be some things you can do in SQL but not in LINQ
  • Without understanding what's going on, it's easy to write very inefficient code
  • It's hard to write a LINQ provider. This may well be inevitable, but more guidance from Microsoft would be appreciated.
  • It's a new way of thinking about data access for most developers, and will need time for understanding to percolate
  • Not specifically LINQ but related to it - the way extension methods are discovered in C# isn't granular enough
  • Some operators are "missing", particularly the equivalents of OrderBy for things other than ordering - e.g. finding the item with the maximum value of a property
  • Deferred execution and streaming are poorly understood (but improving)
  • Debugging can be very tricky due to deferred execution and streaming

我发现它时,在进程查询处理是最好的。它们很容易predict,理解和扩展。互补的技术,如LINQ到XML和并行LINQ是巨大的。 LINQ到对象几乎可以在任何地方使用。

I find it's best when dealing with in-process queries. They're easy to predict, understand and extend. Complementary technologies like LINQ to XML and Parallel LINQ are great. LINQ to Objects can be used almost anywhere.

的LINQ to SQL等等都很好,他们是合适的,但他们很难理解,需要更多的专业知识。他们还只适用于你的code某些领域。

LINQ to SQL etc are really nice where they're appropriate, but they're harder to understand and need more expertise. They're also only applicable in certain areas of your code.

这篇关于优点和LINQ的缺点(语言集成查询)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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