EntityRegister[estore]
在 entity store estore 中注册实体,以便可用 Entity 直接访问这些实体.
EntityRegister
EntityRegister[estore]
在 entity store estore 中注册实体,以便可用 Entity 直接访问这些实体.
更多信息
- EntityStores[] 给出内容已被注册的实体存储列表.
- Entity["type","name"] 被解释为包含 "type" 的 EntityStores[ ] 中第一个实体存储内的实体.
- 在内置实体类型之前,先考虑出现在 EntityStores[] 中的实体类型.
- 在赋值 Entity["type","name"][property]=value 中,数据被存储在包含 "type" 的 EntityStores[ ] 中的第一个 EntityStore 内. 如果 EntityStores[] 中没有 EntityStore 包含 "type",那么会注册一个新的 EntityStore.
- EntityRegister[…] 返回已注册的实体类型列表.
范例
打开所有单元 关闭所有单元基本范例 (2)
EntityRegister[EntityStore["fruit" -> <|
"Entities" -> <|
"banana" -> <|"color" -> Yellow|>,
"strawberry" -> <|"color" -> Red|>
|>
|>]]EntityList["fruit"]Entity["fruit", "banana"]["color"]Entity["fruit", "kiwi"]["color"] = Green;Entity["fruit"]["EntityStore"]EntityStores[]EntityUnregister["fruit"]注册一个基于 SQL 的 EntityStore:
EntityRegister[EntityStore[RelationalDatabase[FindFile["ExampleData/ecommerce-database.sqlite"]]]]范围 (2)
Entity["MyType1", "e"]["p"] = 915;
Entity["MyType2", "f"]["q"] = "abc";EntityStores[]EntityUnregister /@ {"MyType1", "MyType2"};如果想要将数据导入同一实体存储,在赋值之前注册一个包含这两种类型的存储:
EntityRegister[EntityStore[{"MyType1", "MyType2"}]];Entity["MyType1", "e"]["p"] = 915;
Entity["MyType2", "f"]["q"] = "abc";EntityStores[]EntityUnregister["MyType1"]EntityStores[]EntityRegister[EntityStore[{
"t1" -> <|
"Entities" -> <|"e" -> <|"p" -> Entity["t2", "f"]|>|>
|>,
"t2" -> <|
"Entities" -> <|"f" -> <|"q" -> 19|>|>
|>
}]]Entity["t1", "e"]["p"]
%["q"]EntityRegister[EntityStore[
"t2" -> <|
"Entities" -> <|"f" -> <|"q" -> 7891|>|>
|>
]];现在存储 Entity["t2","f"] 指代的是新注册的存储中的实体:
Entity["t1", "e"]["p"]
%["q"]EntityUnregister["t2"]Entity["t1", "e"]["p"]
%["q"]EntityUnregister["t1"]可能存在的问题 (1)
在处理外部数据库时,可能会遇到一个数据库,其中没有为某些表设置主键:
EntityRegister[EntityStore[RelationalDatabase[URLDownload[CloudObject["https://www.wolframcloud.com/obj/documentation/nopk.sqlite"]]]]]这种情况下,EntityStore 将发出一条消息. 这意味着将禁用涉及单个实体的某些功能:
EntityList["table"]但是 EntityValue 一般依然可用:
EntityValue["table", "col"]技术笔记
相关指南
-
▪
- 知识表示和访问 ▪
- 使用关系数据库中的信息 ▪
- 实体类型
文本
Wolfram Research (2018),EntityRegister,Wolfram 语言函数,https://reference.wolfram.com/language/ref/EntityRegister.html.
CMS
Wolfram 语言. 2018. "EntityRegister." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/EntityRegister.html.
APA
Wolfram 语言. (2018). EntityRegister. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/EntityRegister.html 年
BibTeX
@misc{reference.wolfram_2026_entityregister, author="Wolfram Research", title="{EntityRegister}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/EntityRegister.html}", note=[Accessed: 13-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_entityregister, organization={Wolfram Research}, title={EntityRegister}, year={2018}, url={https://reference.wolfram.com/language/ref/EntityRegister.html}, note=[Accessed: 13-September-2026]}