惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 破甲

转:Chrome调试工具介绍 转:一组jQuery插件的连接 动态的链式传递执行 关于导出属性 Aop中动态横切与静态横切 老张的灵魂——敏捷回顾 LINQ to SQL(LINQ2SQL) vs. ADO.NET Entity Framework(ADOEF)-ccBoy版 ---阅读笔记 linq to sql 与linq to entities的选择 linq to sql 算ORM吗? 匿名方法实现(转) System.Linq扩张方法Where (Lambda表达式) Oracle的并发多版本 读一致性 共享锁 排他锁 LINQ与HQL (二) LINQ 与 HQL (一) C# 3.0的新特性(一) 挖掘ADO.NET Entity框架的性能 castle ar 的update方法!! HQL查询中的几个函数
LING与HQL(三)
破甲 · 2008-03-14 · via 博客园 - 破甲

常用查询:
    LINQ:
      from c in ctx.Customers select c
    HQL:
       from Customers c 
  比较一下,区别还是有的 ;注意HQL中Customers 是个领域模型;LINQ中的ctx是DataContext实例;
  既然他们都是对象化的查询,那下面的例子:
     LINQ:
      from c in ctx.Customers
         where c.ContractorName == ”tom“  select new {obj = c.ContractorName}
    HQL:
       from Customers c where c.ContractorName = ?   
      // "?"表示传入的参数 ,上面的两个例子中的c都可以看成一个对象,
  在如:
      LINQ:
       from c in ctx.Customers 
           where c.Orders.Count > 0 select c
        //Customers 和 Orders 是主外键关系
      HQL:
       from Orders o where o. Customers.ContractorName = ?  
       //o表示Orders这个对象,它的属性Customers也是一个对象
      select Customers from Orders o where o. Customers.ContractorName = ?  
      //在HQL中可以通过select 返回其他对象

使用排序:
     LINQ:
        from c in ctx.Employees 
           where c.Employees.Count >0
           orderby c.EmployeeID descending , c.ReportsTo ascending 
           select c
      注意,因为Employees 有个自链接,

[ReportsTo] REFERENCES [EmployeeID],所以有c.Employees.Count >0
这个;
     HQL:
        from Customers c order by c.EmployeeID desc, c.ReportsTo asc
    这里HQL的排序方式和T-SQL一样;

使用分组:
    简单分组:
    LINQ:
      from c in ctx.Employees
        group c by c.ReportsTo
      select c
    HQL:
      from Employees e group by e.EmployeeID
  带条件的分组:
     LINQ:
      from c in ctx.Employees
        group c by c.ReportsTo into tmp
        where tmp.Count() > 0
      select new { 分组数 = tmp.Count()}
    HQL:
      select count(e) from Employees e
         group by e.EmployeeID 
         having  e.EmployeeID = 11