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

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - huangyi

垃圾回收 郁闷 MyConsole 白做了 Winform程序中打开控制台 心目中软件开发的未来 把新闻系统转到CommunityServer下的几点体会 css学习笔记 Float css学习笔记 Position CommunityServer下的新闻系统 qq 被人骗走了啊 狗日的 2千多个小时啊 Enterprise Library CommunityServer如何管理Url CommuntyServer架构分析 web2.0 与 未来网 论坛 博客 相册 留言本 开发计划 微软技术一个共同点 学习avalon的第一个小程序 献丑了 与delphi有关 看到Agent Oriented Programmig感想 Introduce Longhorn to developers(The Longhorn Application Model)[翻译]
CommunityServer如何实现属性的动态扩展
huangyi · 2005-08-09 · via 博客园 - huangyi

拿 forum  做例子
forum继承自section   section继承自ExtendedAttributes
ExtendedAttributes提供了属性动态扩展的功能
ExtendedAttributes中维护一个
NameValueCollection extendedAttributes = new NameValueCollection();
保存所有扩展属性
先来看下forum中定义的一个扩展属性

通过Get/Set ExtendedAttributes  在NameValueCollection中存取属性值 
最终通过DataProvidor存到数据库中去,下面是SqlCommonDataProvider.CreateUpdateDeleteSection中的代码

GetSerializerData是 ExtendedAttributes定义的方法  用于将NameValueCollection中保存的属性序列化
Serializer.ConvertFromNameValueCollection(this.extendedAttributes,ref keys, ref values);

在cs中如果想给某个实体加一个属性,  只需要简单地在类中添加一个属性,  数据库的操作都根本不需要考虑。

当然动态扩展的属性不太容易实现检索。如果需要针对扩展属性进行检索的话,还得改数据表。