什么';在breeze中创建复杂类型的未绑定实例的正确方法是什么?
因此,想象一下以下模型:什么';在breeze中创建复杂类型的未绑定实例的正确方法是什么?,breeze,Breeze,因此,想象一下以下模型: class ComplexTypeA { public string ComplexPropertyA } class ParentTypeA { public string ParentPropertyA public ComplextTypeA ParentPropertyB } 现在进入客户端的breeze世界,假设出于各种原因,我需要创建ComplexTypeA的实例并“附加”(我知道它不是附加的,它是复制值,但想不出其他更好的词)稍
class ComplexTypeA
{
public string ComplexPropertyA
}
class ParentTypeA
{
public string ParentPropertyA
public ComplextTypeA ParentPropertyB
}
现在进入客户端的breeze世界,假设出于各种原因,我需要创建ComplexTypeA的实例并“附加”(我知道它不是附加的,它是复制值,但想不出其他更好的词)稍后将其添加到我单独创建的ParentTypeA实例
简单地说,最好的方法是什么?我成功地实现了这一目标,但目前,情况是这样的:
manager.metadataStore.getEntityType('ParentTypeA').complexProperties[0].dataType.createInstance()
如果这是正确的方式,那么冷静,我会给自己一颗金星。虽然我担心文档会让它看起来容易很多,但我刚刚找到了一种新的创造性的方法,可以在以后的日子里打自己的脚
这实际上有点不正确,您可以创建“未绑定”
使用complexType.createInstance
方法的complexType的实例
但当您分配它时,您只是将其值复制到
现有实例
谢谢 请参阅ComplexType.createInstance方法: 例如:
// The MetadataStore.getEntityType method returns both EntityTypes and ComplexTypes.
var locationType = myEntityManager.metadataStore.getEntityType("Location");
// creates a newLocation complex object with all default values
var newLocation = locationType.createInstance();
// or create a fully fleshed out version.
// var newLocation = locationType.createInstance( { city: "San Francisco", street: "111 Main Street", state: "CA" });
我也有同样的问题。太好了,谢谢。我不确定getEntityType的行为是否如此。