我是如何在JayData上创建实体间关系的?
这是我的表模式:
$data.Entity.extend("OrdemServico", {
Status: { type: String },
SafAnoSafra: { type: "int" },
LancObservacao: { type: String },
LancDtPrevIni: { type: Date },
LancDtPrevFim: { type: Date },
LancData: { type: Date },
CodSubprocesso: { type: "int" },
CodProcesso: { type: "int" },
CodOs: { type: "int" },
CodFuncEmpr: { type: "int" },
CodFuncAplic: { type: "int" },
CodFuncApliEmpr: { type: "int" },
CodFunc: { type: "int" },
CodFrente: { type: "int" },
CodEmpr: { type: "int" }
});
$data.Entity.extend("Local", {
SafAnoSafra: { type: "int" },
PerAreaOs: { type: "decimal" },
IdDivi4: { type: "int" },
CodOs: { type: "int" },
CodEmpr: { type: "int" },
CodDivi4: { type: "int" },
CodDivi3: { type: "int" },
CodDivi2: { type: "int" },
CodDivi1: { type: "int" },
AreaOs: { type: "decimal" },
AreaLiquida: { type: "decimal" }
});这种关系是:
OrdemServico.SafAnoSafra -> Local.SafAnoSafra
OrdemServico.CodEmpr -> Local.CodEmpr
OrdemServico.CodOs -> Local.CodOs经过大量的搜索,我在官方的JayData教程中找到了一些与此相关的东西,但在此链接上(至少对我来说)还不太清楚。根据它,我要做的是建立一种关系,比如:
Locais: {type: "Array", elementType: "$org.types.Local", navigationProperty: "OrdemServico"}的OrdemServico实体..。
本地实体的OrdemServico: { type: "Array", elementType: "$org.types.OrdemServico", navigationProperty: "Local"}。
它破坏了我的代码,不起作用。不知道怎么走得更远。
发布于 2013-08-07 15:25:31
查看JayData主页上的代码片段-查找“关系”。
我解释了基本知识,用一个最新的例子说明了这一点:
$data.Entity.extend("Todo", {
Id: { type: "int", key: true, computed: true },
Task: { type: String, required: true, maxLength: 200 },
Person: { type: "Person", required: true, inverseProperty: "Todos"}
});
$data.Entity.extend("Person", {
Id: { type: "int", key: true, computed: true },
Name: { type: String, required: true, maxLength: 200 },
Todos: { type: Array, elementType: Todo, inverseProperty: "Person" }
});
$data.EntityContext.extend("TodoDatabase", {
Todos: { type: $data.EntitySet, elementType: Todo },
People: { type: $data.EntitySet, elementType: Person }
});Todo实体:我们将Person导航属性定义为引用字段,其类型为"Person“-将在以后声明。必须设置inverseProperty,以便让JayData帮助您找到关系的另一面。
Person实体: One person可以有多个待办事项,因此我们定义了一个todos集合。elementType定义集合中项的类型。这里也需要inverseProperty。
注意: navigationProperty在早期版本的JayData中是有效的,根据开发人员社区的反馈,它被重命名为inverseProperty。不幸的是,这一页现在不是updated...until了.谢谢你的提问,让我们知道你是否还发现令人困惑的信息,我们真的想有清晰和最新的文件,但我们有很多内容,我们只能用你的反馈。谢谢!
https://stackoverflow.com/questions/17980861
复制相似问题