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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LINUX DO - 最新话题
Recorded Future
Recorded Future
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗
宝玉的分享
宝玉的分享
量子位
雷峰网
雷峰网
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Vercel News
Vercel News
L
LangChain Blog
B
Blog
Y
Y Combinator Blog
爱范儿
爱范儿
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
博客园 - Franky
P
Palo Alto Networks Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
Scott Helme
Scott Helme
I
Intezer
T
The Exploit Database - CXSecurity.com
MyScale Blog
MyScale Blog
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Troy Hunt's Blog
N
News and Events Feed by Topic
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Security Affairs
Cyberwarzone
Cyberwarzone
PCI Perspectives
PCI Perspectives
小众软件
小众软件
D
DataBreaches.Net
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
S
Securelist
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
The Last Watchdog
The Last Watchdog

博客园 - 木人(我现在不是老大)

ERP系统的专业化发展趋势 讨厌的real和float数据 Svcutil使用点滴 windows server2003企业版64位安装sql server2008企业版64位 读书笔记 UltraGrid(16) 水晶报表使用push模式(1) SQL SERVER2000存储过程调试 读书笔记 UltraGrid(15) 读书笔记 UltraGrid(14) 读书笔记 UltraGrid(12) 读书笔记 UltraGrid(11) 读书笔记 UltraGrid(10) 读书笔记 UltraGrid(9) 读书笔记 UltraGrid(8) 读书笔记 UltraGrid(7) 读书笔记 UltraGrid(6) 读书笔记 UltraGrid(5) 读书笔记 UltraGrid(4) 读书笔记 UltraGrid(3)
水晶报表使用push模式(2)
木人(我现在不是老大) · 2012-02-25 · via 博客园 - 木人(我现在不是老大)

1.考虑如何存储设计所需的数据模型?
实际上我们可以认为,每张基表就是粒度最细的数据模型,只是某些字段是代码性质,不适合于最终用户去使用而已。
所以我们建立基表的时候是否可以考虑把列的友好名称保存,以便我们建立数据模型的时候引用。
实际上这些数据可以认为是整个系统的元数据之一,包括界面、数据模型等需要的地方都可以引用。
保存在哪里?
第一,使用系统的机制,保存在系统表中;
第二,也可以自己设计表来保存。当然若是前者的话,在企业管理器中也可以查看到,方便数据库管理员使用。

有了基表数据后,我们就可以通过基表来建立我们的数据模型了。
通常我们可以构建一个视图,其列信息可从基表中获得。
我们可以通过sysdepends获取其依赖的表、视图以及其相应的列,从而可通过sysproperties获取其列的信息。
示例如下:
select distinct d.id,c.name,p.value from sysdepends as d inner join sysobjects as o on d.depid=o.id
inner join syscolumns as c on d.depid=c.id and d.depnumber=c.colid
left join sysproperties   p on p.id=c.id and   p.smallid=c.colid
where d.id =object_id(@ModelName)
2.如何获取数据
借用ado.net中的概念,考虑在源数据和数据模型间有一个适配器,这个适配器用于从源数组织数据,从而形成符合数据模型结构的数据。
实际中适配器通常就是一段查询语句,该语句基于数据模型生成。当然,也可能是一个存储过程,用于生成来源复杂、计算复杂的数据。
3.如何过滤数据
仔细考虑,我们可以发现过滤的条件不超乎数据模型所约定的范围。所以,我们可以根据数据模型来设置过滤的条件。因为数据模型中包括
了字段名、数据类型等,所以我们很方便根据这些内容形成查询语句。示例如下:
StringBuilder sb=new StringBuilder("select * from "+DataModel);
sb.Append(" ");
sb.Append("Where");
sb.Append(" ");
sb.Append(columnName);
sb.Append(" ");
sb.Append(operator);
sb.Append(" ");
sb.Append("@" + columnName);
sb.Append(" ");
同样,根据这些设置的过滤条件及值,我们也很方便形成SqlParameter,从而通过SqlDataAdapter获取数据。
对于存储过程,我们的过滤条件不会超过存储过程中所包含的参数。当然存储过程本身的参数受数据模型本身的限制。
我们可以通过SqlCommandBuilder.DeriveParameters(cmd)获取其包含的参数,从而形成过滤条件的设置信息。