i have never used LINQ in any of my projects , i have always used ado.net /OR tool in my Business App projects , so i want to know What are the benefits of LINQ ? why and when anybody should use LINQ ?
我从未在任何项目中使用LINQ,我一直在我的商业应用项目中使用ado.net / OR工具,所以我想知道LINQ有什么好处?为什么以及何时应该使用LINQ?
4 个解决方案
#1
11
Just to clarify there are differences between the concept of LINQ and LINQ to SQL.
只是为了澄清LINQ和LINQ to SQL的概念之间存在差异。
LINQ is a query syntax, not a language or an O/RM. You can build an O/RM on top of the syntax provided by LINQ.
LINQ是一种查询语法,而不是语言或O / RM。您可以在LINQ提供的语法之上构建O / RM。
Since I gather that your question is really When to use LINQ to SQL I'll just address that.
因为我认为你的问题确实是什么时候使用LINQ to SQL我只会解决这个问题。
LINQ to SQL is best used when you are:
LINQ to SQL最适用于以下情况:
- Only ever targeting MS SQL 2000+
- Doing RAD
只针对MS SQL 2000+
I've used LINQ to SQL on a couple of commercial products and quite a few of my own products and found these benefits:
我在几种商业产品和我自己的产品中使用了LINQ to SQL,并发现了以下好处:
- Familiar language to code in (C#/ VB.NET)
- Easier to maintain (we have more .NET than SQL gurus on staff)
- SQL generated is well structured and very optimal
- Allows direct translation of business rules to SQL while still keeping all business logic in a single project
熟悉的语言代码(C#/ VB.NET)
易于维护(我们的.NET比工作人员的SQL专家更多)
生成的SQL结构良好且非常优化
允许将业务规则直接转换为SQL,同时仍将所有业务逻辑保留在单个项目中
As for LINQ as a concept I use it all the time, because I understand what it can/can't do and how to use it properly. Like any language feature it can be miss-used easily if people don't have an understanding of what it is and how to use it. I recommend the following blogs to get some of the concepts of LINQ down:
至于LINQ作为一个概念,我一直都在使用它,因为我理解它能做什么/不能做什么以及如何正确使用它。与任何语言功能一样,如果人们不了解它是什么以及如何使用它,它可能很容易被错过使用。我推荐以下博客来了解LINQ的一些概念:
- Bart De Smet - advanced
- Charlie Calvert
- Wriju
Bart De Smet - 先进
#2
3
This is a fair question but has been asked many times already. See these earlier questions for a more in depth and broader coverage:
这是一个公平的问题,但已经多次被问过。请参阅这些早期问题,以获得更深入,更广泛的报道:
关于Linq
Linq初学者指南
What's the hardest or most understood aspect of Linq
Linq最难或最了解的方面是什么?
#3
1
LINQ is some kind of universal query language. If you learn it you don't have to limit yourself to the database but you can also use it to manipulate XML files, or JSON files or arrays, Lists<> and dictionairies<,> . It's great.
LINQ是某种通用查询语言。如果您了解它,则不必将自己限制在数据库中,但您也可以使用它来操作XML文件,或JSON文件或数组,Lists <>和dictionairies <,>。这很棒。
There is even LinqToFlickr, LinqToExcel and LinqToGoogle. It is much more than an OR mapper. See: http://blogs.msdn.com/charlie/archive/2008/02/28/link-to-everything-a-list-of-linq-providers.aspx
甚至还有LinqToFlickr,LinqToExcel和LinqToGoogle。它不仅仅是一个OR映射器。请参阅:http://blogs.msdn.com/charlie/archive/2008/02/28/link-to-everything-a-list-of-linq-providers.aspx
#4
0
LINQ-to-SQL functions well as a light-weight ORM via the DMBL designer. It has built-in language support and makes it pretty easy to access your entities using standard access patterns. I use it in all of my new projects and find that it is a significant improvement for me in simplicity and testability. There is a lot more info at this post.
LINQ-to-SQL可以通过DMBL设计器实现轻量级ORM。它具有内置的语言支持,并且使用标准访问模式可以非常轻松地访问您的实体。我在所有新项目中都使用它,发现它在简单性和可测试性方面对我来说是一个重大改进。这篇文章有更多信息。
#1
11
Just to clarify there are differences between the concept of LINQ and LINQ to SQL.
只是为了澄清LINQ和LINQ to SQL的概念之间存在差异。
LINQ is a query syntax, not a language or an O/RM. You can build an O/RM on top of the syntax provided by LINQ.
LINQ是一种查询语法,而不是语言或O / RM。您可以在LINQ提供的语法之上构建O / RM。
Since I gather that your question is really When to use LINQ to SQL I'll just address that.
因为我认为你的问题确实是什么时候使用LINQ to SQL我只会解决这个问题。
LINQ to SQL is best used when you are:
LINQ to SQL最适用于以下情况:
- Only ever targeting MS SQL 2000+
- Doing RAD
只针对MS SQL 2000+
I've used LINQ to SQL on a couple of commercial products and quite a few of my own products and found these benefits:
我在几种商业产品和我自己的产品中使用了LINQ to SQL,并发现了以下好处:
- Familiar language to code in (C#/ VB.NET)
- Easier to maintain (we have more .NET than SQL gurus on staff)
- SQL generated is well structured and very optimal
- Allows direct translation of business rules to SQL while still keeping all business logic in a single project
熟悉的语言代码(C#/ VB.NET)
易于维护(我们的.NET比工作人员的SQL专家更多)
生成的SQL结构良好且非常优化
允许将业务规则直接转换为SQL,同时仍将所有业务逻辑保留在单个项目中
As for LINQ as a concept I use it all the time, because I understand what it can/can't do and how to use it properly. Like any language feature it can be miss-used easily if people don't have an understanding of what it is and how to use it. I recommend the following blogs to get some of the concepts of LINQ down:
至于LINQ作为一个概念,我一直都在使用它,因为我理解它能做什么/不能做什么以及如何正确使用它。与任何语言功能一样,如果人们不了解它是什么以及如何使用它,它可能很容易被错过使用。我推荐以下博客来了解LINQ的一些概念:
- Bart De Smet - advanced
- Charlie Calvert
- Wriju
Bart De Smet - 先进
#2
3
This is a fair question but has been asked many times already. See these earlier questions for a more in depth and broader coverage:
这是一个公平的问题,但已经多次被问过。请参阅这些早期问题,以获得更深入,更广泛的报道:
关于Linq
Linq初学者指南
What's the hardest or most understood aspect of Linq
Linq最难或最了解的方面是什么?
#3
1
LINQ is some kind of universal query language. If you learn it you don't have to limit yourself to the database but you can also use it to manipulate XML files, or JSON files or arrays, Lists<> and dictionairies<,> . It's great.
LINQ是某种通用查询语言。如果您了解它,则不必将自己限制在数据库中,但您也可以使用它来操作XML文件,或JSON文件或数组,Lists <>和dictionairies <,>。这很棒。
There is even LinqToFlickr, LinqToExcel and LinqToGoogle. It is much more than an OR mapper. See: http://blogs.msdn.com/charlie/archive/2008/02/28/link-to-everything-a-list-of-linq-providers.aspx
甚至还有LinqToFlickr,LinqToExcel和LinqToGoogle。它不仅仅是一个OR映射器。请参阅:http://blogs.msdn.com/charlie/archive/2008/02/28/link-to-everything-a-list-of-linq-providers.aspx
#4
0
LINQ-to-SQL functions well as a light-weight ORM via the DMBL designer. It has built-in language support and makes it pretty easy to access your entities using standard access patterns. I use it in all of my new projects and find that it is a significant improvement for me in simplicity and testability. There is a lot more info at this post.
LINQ-to-SQL可以通过DMBL设计器实现轻量级ORM。它具有内置的语言支持,并且使用标准访问模式可以非常轻松地访问您的实体。我在所有新项目中都使用它,发现它在简单性和可测试性方面对我来说是一个重大改进。这篇文章有更多信息。