Olingo:EntityContainer 和 EntitySets 的区别
Olingo: EntityContainer and EntitySets differences
我正在阅读此 documentation 以了解如何创建 odata 服务。
我不太明白 EntityContainer
和 EntitySet
是什么...
[编辑]
请教一个我还不太明白的误会。如果EntitySet
直接是一组实体:
为什么我需要在我的 OData 提供程序上实施 EntitySet CsdlAbstractEdmProvider.getEntitySet()
方法?正如您在 here 上看到的那样,我需要实现此 returns 和 EntitySet
的方法。这是 Olingo 文档中的实现:
public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer, String entitySetName) {
if(entityContainer.equals(CONTAINER)){
if(entitySetName.equals(ES_PRODUCTS_NAME)){
CsdlEntitySet entitySet = new CsdlEntitySet();
entitySet.setName(ES_PRODUCTS_NAME);
entitySet.setType(ET_PRODUCT_FQN);
return entitySet;
}
}
return null;
}
我不太明白这个实现的目的是什么。
另一方面,在 EntityCollectionProcessor
documentation implementation 上,您可以看到他们也在使用 EntitySet
。
我不明白提供者内部和处理器内部 EntitySet
之间的区别是什么。
不知道我有没有解释的这么好
基于 OData documentation,第 4.1 节:
The central concepts in the EDM are entities and associations. Entities are instances of Entity Types (for example, Customer, Employee, and so on) which are structured records consisting of named and typed properties and with a key. Complex Types are structured types also consisting of a list of properties but with no key, and thus can only exist as a property of a containing entity or as a temporary value. An Entity Key is formed from a subset of properties of the Entity Type. The Entity Key (for example, CustomerId or OrderId) is a fundamental concept for uniquely identifying instances of Entity Types and allowing Entity Type instances to participate in relationships. Entities are grouped in Entity Sets (for example, Customers is a set of Customer Entity Type instances).
Associations define the relationship between two or more Entity Types (for example, Employee WorksFor Department). Instances of associations are grouped in Association Sets. Navigation Properties are special properties on Entity Types which are bound to a specific association and can be used to refer to associations of an entity.
Finally, all instance containers (Entity Sets and Association Sets) are grouped in an Entity Container.
总结:
- 一个EntitySet是一组Entity。通常,EntitySet 是一个业务对象;要使用关系数据库比较,请将 EntitySet 视为 table 并将实体视为 table.
中的一行
- EntityContainer 就是 EntitySet 和关联的容器。粗略地说,您可以将其视为一个数据库,其中包含您的 table、视图等
希望对您有所帮助。
编辑,根据您的问题更改:
Provider.getEntitySet()方法和Processor.getEntitySet()方法的区别归结为差异出于提供者和处理者的目的 classes.
- Provider class 定义 OData 服务的结构和元数据。 getEntitySet 方法定义每个实体集的结构(名称和类型)。
- 处理器 class 本质上是 OData 服务的 servlet。在这里,HTTP 请求被解析、处理和重定向(到您的服务或 DAO 层)。 getEntitySet方法,在processor中,用来处理这种结构的请求:(host and port)/(service root.svc)/(MyEntitySet) ,例如:http://services.odata.org/V3/Northwind/Northwind.svc/Customers。在此方法中,确定已请求哪个实体集,然后相应地调用您的 DAO 来获取您的数据。
我正在阅读此 documentation 以了解如何创建 odata 服务。
我不太明白 EntityContainer
和 EntitySet
是什么...
[编辑]
请教一个我还不太明白的误会。如果EntitySet
直接是一组实体:
为什么我需要在我的 OData 提供程序上实施 EntitySet CsdlAbstractEdmProvider.getEntitySet()
方法?正如您在 here 上看到的那样,我需要实现此 returns 和 EntitySet
的方法。这是 Olingo 文档中的实现:
public CsdlEntitySet getEntitySet(FullQualifiedName entityContainer, String entitySetName) {
if(entityContainer.equals(CONTAINER)){
if(entitySetName.equals(ES_PRODUCTS_NAME)){
CsdlEntitySet entitySet = new CsdlEntitySet();
entitySet.setName(ES_PRODUCTS_NAME);
entitySet.setType(ET_PRODUCT_FQN);
return entitySet;
}
}
return null;
}
我不太明白这个实现的目的是什么。
另一方面,在 EntityCollectionProcessor
documentation implementation 上,您可以看到他们也在使用 EntitySet
。
我不明白提供者内部和处理器内部 EntitySet
之间的区别是什么。
不知道我有没有解释的这么好
基于 OData documentation,第 4.1 节:
The central concepts in the EDM are entities and associations. Entities are instances of Entity Types (for example, Customer, Employee, and so on) which are structured records consisting of named and typed properties and with a key. Complex Types are structured types also consisting of a list of properties but with no key, and thus can only exist as a property of a containing entity or as a temporary value. An Entity Key is formed from a subset of properties of the Entity Type. The Entity Key (for example, CustomerId or OrderId) is a fundamental concept for uniquely identifying instances of Entity Types and allowing Entity Type instances to participate in relationships. Entities are grouped in Entity Sets (for example, Customers is a set of Customer Entity Type instances).
Associations define the relationship between two or more Entity Types (for example, Employee WorksFor Department). Instances of associations are grouped in Association Sets. Navigation Properties are special properties on Entity Types which are bound to a specific association and can be used to refer to associations of an entity.
Finally, all instance containers (Entity Sets and Association Sets) are grouped in an Entity Container.
总结:
- 一个EntitySet是一组Entity。通常,EntitySet 是一个业务对象;要使用关系数据库比较,请将 EntitySet 视为 table 并将实体视为 table. 中的一行
- EntityContainer 就是 EntitySet 和关联的容器。粗略地说,您可以将其视为一个数据库,其中包含您的 table、视图等
希望对您有所帮助。
编辑,根据您的问题更改:
Provider.getEntitySet()方法和Processor.getEntitySet()方法的区别归结为差异出于提供者和处理者的目的 classes.
- Provider class 定义 OData 服务的结构和元数据。 getEntitySet 方法定义每个实体集的结构(名称和类型)。
- 处理器 class 本质上是 OData 服务的 servlet。在这里,HTTP 请求被解析、处理和重定向(到您的服务或 DAO 层)。 getEntitySet方法,在processor中,用来处理这种结构的请求:(host and port)/(service root.svc)/(MyEntitySet) ,例如:http://services.odata.org/V3/Northwind/Northwind.svc/Customers。在此方法中,确定已请求哪个实体集,然后相应地调用您的 DAO 来获取您的数据。