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

推荐订阅源

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的并发多版本 读一致性 共享锁 排他锁 LING与HQL(三) LINQ 与 HQL (一) C# 3.0的新特性(一) 挖掘ADO.NET Entity框架的性能 castle ar 的update方法!! HQL查询中的几个函数
LINQ与HQL (二)
破甲 · 2008-03-12 · via 博客园 - 破甲

   C# 3.0提供System.Data.Linq.DataContext这么一个非常重要的类型,对LINQ来说;DataContext提供了实体对象与数据对象之间的访问通道;
   public class CustomersCtx : DataContext
   {
       public Table<Customer>  Customers;
       public CustomersCtx(string connString) : base(connString) {.....}
    }
  下面我们看看DataContext和LINQ结合后的强大功能;
   CustomersCtx ctx = new CustomersCtx("数据连接串");
   var  list = from c in ctx.Customers select c;
   var list1 = from c in ctx.Customers where c.ContactorName == '43434'
                    select new {id = c.ID,name = c.ContactorName};

   感觉是不是很简洁,其实现在ASP.NET ENTITY也提供类似的访问方式;
   另外DataContext还提供很多功能,比如日志功能,通过日志我们可以看到LINQ是如何转化为标准SQL的;例如:ctx.log = new StreamWriter("日志文件"):
   在补充一个功能,肯能对写单元测试有用,,就是DataContext提供了Create table 和Delete Table 的能力,所以在单元测试的TestBase里能很有用,(以前用castle 的时候,也是利用castLe类似的功能来初始化数据库)

   除此以外DataContext还提供了与ADO.NET的接口,可以方便使用传统ado.net的数据访问方式访问关系数据库;(类似的做法castle ,nhernate 也有)这两种ORM工具还支持HQL和SQL的访问方式;