C#中的Linq概念 [英] Concept of Linq in C#

查看:86
本文介绍了C#中的Linq概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我正在努力围绕Linq的概念……我说的对,这基本上是使用类似于T-SQL的代码访问数据的一种方式.

如果使用Linq,是否需要T-SQL?存储过程是必需的还是可以/应该使用Linq来构建它们?

请原谅我的无知...我一直在阅读的文章和视频对此并不十分简洁.

预先感谢您的宝贵时间,

Suraci

Hello all!

I am trying to wrap my head around the concept of Linq... am I correct when I say it''s basically a way to access data using code kind of resembling T-SQL.

Is there any need for T-SQL if using Linq? Are stored procedures necessary or can/should you just build them with Linq?

Please forgive my ignorance... the articles and videos i''ve been reading are not very concise about it.

Thank you in advance for your time,

Suraci

推荐答案

对不起,苏拉奇,

这个概念是完全相反的. LINQ旨在查询应用程序对象.没有什么可以处理数据库对象的.要检索数据库对象,您仍然需要T-SQL和Sql存储过程.

现在,如果您的应用程序要在用户过滤时在应用程序末尾过滤数据结果,则无需再次从数据库中获取过滤后的数据,而是可以使用现有数据并以与执行过滤操作相同的方式轻松过滤对象在数据库中.分组,联接等功能使您可以在应用程序端筛选critera,如果您使用常规循环手动进行操作,则需要大量代码.

请看一下我在LINQ上的文章.我认为示例可能会消除您的大部分疑问

http://www.codeproject.com/KB/dotnet/LINQ.asp [ ^ ]
Sorry Suraci,

The concept is totally opposite. LINQ is intended to query application objects. There is nothing to deal with Database objects. To retrieve database object you still require T-SQL and Sql Stored Procedures.

Now if your application wants to filter the data result in application end when the user filters, you dont need to get the filtered data again from the database, rather you can use the existing data and easily filter the objects in the same way as you do in database. The capability of Grouping, Joining etc gives you an edge to filter critera in application end which would require lots of code if you do manually using normal loops.

Please take a look of my article on LINQ. I think examples might clear most of your doubts

http://www.codeproject.com/KB/dotnet/LINQ.asp[^]


这篇关于C#中的Linq概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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