[摘抄] 为什么 Linq 可以高效率查询 SQL ?

From C# in Depth(3rd) - Jon Skeet

using (LinqDemoDataContext db = new LinqDemoDataContext())
{
var filtered = from p in db.Products
join s in db.Suppliers
on p.SupplierID equals s.SupplierID
where p.Price > 10
orderby s.Name, p.Name
select new { SupplierName = s.Name, ProductName = p.Name };
foreach (var v in filtered)
{
Console.WriteLine("Supplier={0}; Product={1}",
v.SupplierName, v.ProductName);
}
}

  

That’s impressive enough, but if you’re performance-conscious, you may be wondering
why you’d want to pull down all the data from the database and then apply
these .NET queries and orderings. Why not get the database to do it? That’s what it’s
good at, isn’t it? Well, indeed—and that’s exactly what LINQ to SQL does. The code in
listing 1.18 issues a database request, which is basically the query translated into SQL.
Even though you’ve expressed the query in C# code, it’s been executed as SQL.

时间: 2024-09-30 19:36:42

[摘抄] 为什么 Linq 可以高效率查询 SQL ?的相关文章

ASP.NET - LINQ 语言集成查询

LINQ(Language Integrated Query) LINQ语言集成查询是一组用于C#语言的扩展.它允许编写C#代码对数据集进行查询,这等同于使用数据库查询语句,这样程序员不必掌握数据库查询语句而是使用Linq就能完成相同的查询任务.而传统数据查询的弱点很多,比如执行简单查询也需要冗长的操作代码,查询语句是字符串格式,无法让编译器执行检查错误及早提示,查询不是强类型,查询参数容易写错,查询结果没有真正面向对象,每次查询取结果还得事先知道列名或列索引,不使用抽象工厂的前提下,查询语句是

Linq语法详细(三种方式:linq、Lambda、SQL语法)

三种方式:linq.Lambda.SQL语法 1.简单的linq语法 //1 var ss = from r in db.Am_recProScheme select r; //2 var ss1 = db.Am_recProScheme; //3 string sssql = "select * from Am_recProScheme"; 2.带where的查询 //1 var ss = from r in db.Am_recProScheme where r.rpId >

linq not in 查询

想要的sql: select A.* from BL_BCSS_Invoice A join BL_BCSS_OfflineInvoice B on A.ID!=B.InvoiceID; 不知道如何写的linq..... from t1 in BL_BCSS_Invoice from t2 in BL_BCSS_OfflineInvoice where t1.ID != t2.InvoiceID select t1; linq not in 查询 or join not in var query

Oracle EBS-SQL (SYS-1): sysadmin_用户职责查询.sql

select fu.user_name 用户名, fu.description 用户说明, frv.RESPONSIBILITY_NAME 职责名称, REQUEST_GROUP_NAME 报表组, (select  ppf.FULL_NAME from apps.per_people_f  ppf where fu.employee_id = ppf.PERSON_ID and trunc(sysdate)  between  trunc(ppf.EFFECTIVE_START_DATE) a

Oracle EBS-SQL (SYS-2): sys_在线用户查询.sql

SELECT fs.USER_NAME,       fu.description,       fs.RESPONSIBILITY_NAME,       fs.USER_FORM_NAME,       fs.TIME,       fs.RESP_APPL_ID,       fs.RESPONSIBILITY_ID,       fs.FORM_ID,       fs.FORM_APPL_ID  FROM FND_SIGNON_AUDIT_VIEW fs,       fnd_user

Oracle EBS-SQL (SYS-3):sys_人员用户名对应关系查询.sql

select fu.user_name 用户名,       fu.description 描述,       (select ppf.FULL_NAME          from per_people_f ppf         where ppf.PERSON_ID = fu.employee_id           and trunc(sysdate) between trunc(ppf.EFFECTIVE_START_DATE) and               trunc(ppf

Oracle EBS-SQL (SYS-10):锁定表查询.sql

/*死锁查询-1*/ SELECT o.object_name, l.session_id,l.process, l.locked_mode FROM v$locked_object l , dba_objects o WHERE o.object_id=l.object_id ------------------------------------------------ /*死锁查询-2*/ select GL.SESSION_ID,         do.object_name,     

Oracle EBS-SQL (SYS-7):表单个性化查询.sql

animation-timing-function animation-timing-function 规定动画的速度曲线.速度曲线定义动画从一套 CSS 样式变为另一套所用的时间.在平常的取值中,主要有以下几个: 值 描述 linear 动画从头到尾的速度是相同的. ease 默认.动画以低速开始,然后加快,在结束前变慢. ease-in 动画以低速开始. ease-out 动画以低速结束. ease-in-out 动画以低速开始和结束. cubic-bezier(n,n,n,n) 在 cub

Oracle EBS-SQL (SYS-5):sys_配置文件查询.sql

select    distinct l.profile_option_name,             v.profile_option_value,             fu.user_nameform     applsys.fnd_profile_option_values v,            apps.fnd_profile_options_vl          l,            apps.fnd_user