非标准1:BreezeJS中的许多关系
我有两个Breeze实体,它们在同一个UI页面中使用,它们是相关的,但我无法确定如何在元数据中定义关系。目前,我正在用代码将它们粘在一起,但我确信一定有一种更轻松的方法 以下是我的实体的(缩短的)元数据:非标准1:BreezeJS中的许多关系,breeze,Breeze,我有两个Breeze实体,它们在同一个UI页面中使用,它们是相关的,但我无法确定如何在元数据中定义关系。目前,我正在用代码将它们粘在一起,但我确信一定有一种更轻松的方法 以下是我的实体的(缩短的)元数据: { "namespace": "Mynamespace", "shortName": "SalesInvoice", "defaultResourceName": "SalesInvoices", "dataProperties": [ { "name":
{
"namespace": "Mynamespace",
"shortName": "SalesInvoice",
"defaultResourceName": "SalesInvoices",
"dataProperties": [
{
"name": "ID",
"dataType": "Int32",
"isPartOfKey": true,
"isNullable": false,
"validators": [
{
"name": "required"
},
{
"name": "integer"
}
]
},
{
"name": "InvoiceNumber",
"dataType": "String",
"isPartOfKey": false,
"isNullable": true,
"validators": [
{
"name": "textMedium"
}
]
}
],
"key": {
"propertyRef": {
"name": "ID"
}
},
"autoGeneratedKeyType": "Identity"
},
{
"namespace": "Mynamespace",
"shortName": "DocUrl",
"defaultResourceName": "DocUrls",
"dataProperties": [
{
"name": "ID",
"dataType": "Int32",
"isPartOfKey": true,
"isNullable": false,
"validators": [
{
"name": "required"
},
{
"name": "integer"
}
]
},
{
"name": "Title",
"dataType": "String",
"isPartOfKey": false,
"isNullable": true,
"validators": [
{
"name": "required"
},
{
"name": "textMedium"
}
]
},
{
"name": "Url",
"dataType": "String",
"isPartOfKey": false,
"isNullable": false,
"validators": [
{
"name": "required"
},
{
"name": "url"
}
]
},
{
"name": "Parent",
"dataType": "String",
"isPartOfKey": false,
"isNullable": false,
"validators": [
{
"name": "required"
},
{
"name": "textMedium"
}
]
},
{
"name": "ParentKey",
"dataType": "Int32",
"isPartOfKey": false,
"isNullable": false,
"validators": [
{
"name": "required"
},
{
"name": "integer"
}
]
}
],
"key": {
"propertyRef": {
"name": "ID"
}
},
"autoGeneratedKeyType": "Identity"
}
在SalesInvoice UI页面中,用户必须能够向GoogleDrive文档添加任意数量的超链接,这些文档存储在DocUrl实体中。通常我会定义一个SalesInvoiceDocument实体,并使用SalesInvoice上的导航属性以标准方式设置1:many关系。现在,问题来了!我还需要为许多其他实体添加超链接。这将导致创建更多实体来存储超链接(例如ProductDocument、CustomerDocument、TransactionDocument等),尽管字段始终与DocLink实体相同
为了避免这种重复(并防止全局搜索文档),我使用Parent和ParentKey字段定义了单个DocUrl实体。在这种情况下,对于新的DocUrl实体,我将父字段设置为“SalesInvoice”(或定义回SalesInvoices的关系的任何唯一字符串),并将ParentKey设置为SalesInvoices的ID值
当我加载一个SalesInvoice实体时,我会加载它的DocUrl实体,其谓词匹配Parent='SalesInvoice'和ParentKey=SalesInvoice.ID
这对我来说就像一个复合键,但我还没有在微风中使用这些。如果我可以在导航属性定义中定义Parent='salesvoicine'位,我认为这样做会奏效,但同样不确定如何做
所以问题是…有没有更好的方法
需要注意的要点:我的服务器后端是定制的PHP代码,所以我不使用任何.NET环境
谢谢