data-service
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

Data Fabric user guide

上次更新日期 2025年6月10日

在项目中使用实体

By using entities created in Data Fabric, you can manage and manipulate data aggregated in a single object, without having to work with it in a granular way. To do so you need Studio v2020.8 or later.

以下示例检索奥运会各个项目所获奖牌数前 10 名的国家/地区的相关数据,以及它们获得的奖牌。

Entities in Data Fabric

Following the steps detailed on the Creating an entity page, we created an entity for storing information about participating nations, the opening and closing dates, and the medals they won.

“奥运会”实体具有以下字段:“名称”、“国家/地区”、“开幕日期”和“闭幕日期”。“奖牌”实体具有以下字段:“国家/地区”、“金牌”、“银牌”、“铜牌”以及奖牌总数。这两个实体通过“关系”标签相互关联。



在 Studio 中导入的实体

在 Studio 的工作流中导入实体。

以下工作流将抓取有关某届奥运会的信息,将数据映射到参数,并将其传递到主工作流。



To do so we defined an argument for each type of information that we are collecting, thus resulting in five imported arguments.



通过使用实体,我们只需导入并使用两个参数即可收集数据。

Note: Entities must be initialized using the new operator, read from Data Fabric or passed through an input argument in a workflow before usage, otherwise assigning or reading their values can cause errors.


收集的数据映射到两个参数(inOlympics YearoutOlympics)、其各自的属性和实体中定义的字段。通过使用实体,我们通过将数据正确映射到其各自的实体字段,减少了传递信息所需的参数个数。

创建数据记录

Once the data was collected, you can use the Create Entity Record activity to add the information to Data Fabric.

In this example, we used the imported arguments to pass the collected information to Data Fabric. The Input and Output records are the values of variables of type Olympics used for passing along the data.



After running the project, the following record was created in Data Fabric:



创建包含结构化数据的记录

Records structured in a data table can be passed along to Data Fabric using the For Each Row activity. In this example, we're invoking a workflow that collects structured data on the number of medals won by each country and passes these records along to Data Fabric.



After running the workflow, the following data is stored in Data Fabric:



通过在“奥运会”实体和“奖牌”实体之间设置关系,两者中的数据记录都可以在另一个实体中使用。例如,“奖牌”实体中的“奥运会”字段的值与相关实体中的值相同。

与查询相关的记录

The Query Entity Records activity can be used to pull up a list of records from Data Fabric. In the following example, we use the activity to query data records from the Olympics entity, allow the user to choose an Olympics edition, and from the Medals entity write the number of medals that each participating country won.



在查询“奥运会”表格时,我们在查询生成器中使用了 Name != NULL 条件。这将遍历“名称”列中的所有记录,并在 listOlympics 变量中输出这些记录,以在“输入对话框”活动中使用。
为了将记录列表显示为选项,我们在“输入对话框”活动中使用了以下 Lambda 表达式 listOlympics.Select(Function (o as Olympics) o.Name).ToArray。或者,也可以使用“遍历循环”活动。
系统会将所选内容映射到 selectedOlympics 变量,并在另一个“查询实体记录”活动中使用所选内容来遍历在特定一届奥运会上所获奖牌的列表。此条件是通过在查询生成器中使用 equals 选项设置的。


可对选定实体和相关的实体记录执行查询。

分页

Data Fabric can potentially store a large number of records. To query only a certain number of records, use the Pagination properties from the Query Entities Records activity. The Top property supports a maximum number of 1,000, this means that 1,000 records can be queried at a time.

本示例先查询前五个记录,然后再查询接下来的五个记录,直到抓取列表中的最后一个记录为止。



为此,我们为 skip Int64 变量分配了初始值 0,然后在每个循环后将其值递增,直到抓取最后一个记录为止。


抓取前五枚奖牌后,使用“遍历循环”活动将参与国家/地区及其所获奖牌数写入到记事本文件。

Update entity schema

The following scenario explains the steps for updating an entity schema in Data Fabric and then syncing the data with Studio.

In Data Fabric, go to the Medals entity, select Create New Field, and add a new column HostCountry of type Yes/No. Select Save.



In Studio, select on Manage Entities, and then the Refresh button. A change was detected for the Medals entity, as illustrated in the Changes column. Select Save and the entity is updated in Studio.



查询和更新记录

The Update Entity Record activity can be used for updating records from your workflow directly into Data Fabric.

在本示例中,我们将从“奖牌”实体查询某些记录,并使用上述活动自动更新这些记录。

“奖牌”实体中,每届奥运会的主办国家名称旁边标有星号。例如,对于 2012 奥运会,主办国家在“奥运会”列中记录为“英国 (GBR)*”。



通过使用“查询实体记录”活动,遍历所有包含星号 (*) 的记录,在 listMedals 变量中抓取记录,使用“遍历循环”活动遍历循环每个项目,并在“主办国家”列中在主办特定一届奥运会的国家旁边分配“True”值。

The Update Entity Record activity can be used in numerous other scenarios for passing along data and updating records in Data Fabric.

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo White
© 2005-2025 UiPath。保留所有权利。