[英]Breeze.js 1.4.1 properties undefined not null
I upgraded to 1.4.1 per the recommendation of Breeze support but I am having the following issue. 根据Breeze支持的建议,我已升级到1.4.1,但存在以下问题。 Previously, the navigation properties on newly created entities where defined, but null valued knockout observables.
以前,已定义新创建实体的导航属性,但可观察到值为空的敲除。 I modified the Breezejs TODO application to show this.
我修改了Breezejs TODO应用程序以显示此内容。
My data model is below, and my front end code is here: 我的数据模型在下面,前端代码在这里:
function reproduce() {
breeze.NamingConvention.camelCase.setAsDefault();
var manager = new breeze.EntityManager(serviceName);
manager.fetchMetadata().then(function () {
var parent = manager.createEntity('Parent');
console.log('otherProperty ' + parent.otherProperty());
console.log('childOne ' + parent.childOne());
// I cannot call parent.childrenTwo() since childrenTwois undefined
console.log('childrenTwo ' + parent.childrenTwo);
});
}
The issue is that in previous versions of breeze, the properties otherProperty and childOne would be a knockout observable with a null value and the property childrenTwo would be an empty observable array. 问题在于,在微风的早期版本中,属性otherProperty和childOne将是具有空值的可观察到的敲除,而属性childrenTwo将是一个可观察的空数组。 However, as I see in the console all three properties are undefined?
但是,正如我在控制台中看到的那样,所有三个属性都未定义? Is this intentional?
这是故意的吗?
I could of course define them myself but that is a lot of work and something I expect breeze todo for me. 我当然可以自己定义它们,但这是很多工作,我希望微风可以为我做。 Also according to the Breeze docs "There is rarely reason to define properties that are already described in metadata."
同样根据Breeze的文档,“很少有理由定义已经在元数据中描述的属性。” http://www.breezejs.com/documentation/extending-entities
http://www.breezejs.com/documentation/extending-entities
Update 1: 更新1:
Thanks to Jay Traband, in my reproduction app I was not setting casing correctly. 感谢Jay Traband,在我的复制应用程序中,我没有正确设置外壳。 However childrenTwo is still undefined and I believe it should be an observable array.
但是childrenTwo仍未定义,我相信它应该是一个可观察的数组。 My production app does set casing so I'll have to re-investigate that.
我的生产应用程序确实设置了大小写,因此我必须对此进行重新调查。
Update 2: 更新2:
Thanks again to Jay Traband, I found that the breeze metastore does not know about the ChildTwo type. 再次感谢Jay Traband,我发现微风的metastore不了解ChildTwo类型。 Therefore it seems I am not registering it somehow?
因此,似乎我没有以某种方式进行注册? I am much more familiar with Java Hibernate than Entity Framework.
我对Java Hibernate比对实体框架更熟悉。 Is something missing from my data model below?
下面的数据模型中缺少什么吗?
Updated 3: 更新3:
ChildTwo didn't have an explicit foreign key, I added that and it worked. ChildTwo没有显式的外键,我补充说,它可以正常工作。 I guess I really need to take to heart that Breeze wants an explicit foreign key.
我想我真的需要深信Breeze需要一个明确的外键。
public class ChildTwo
{
[Key]
public int Id { get; set; }
public int ParentId { get; set; }
[ForeignKey("ParentId")]
public Parent Parent { get; set; }
}
Data model. 数据模型。
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Todo.Models
{
public class Parent
{
public Parent()
{
ChildrenTwo = new List<ChildTwo>();
}
[Key]
public int Id { get; set; }
[Required]
public string OtherProperty { get; set; }
[Required]
public ChildOne ChildOne { get; set; }
[Required]
public IList<ChildTwo> ChildrenTwo { get; set; }
}
public class ChildOne
{
[Key]
[ForeignKey("Parent")]
public int Id { get; set; }
public Parent Parent { get; set; }
}
public class ChildTwo
{
[Key]
public int Id { get; set; }
public Parent Parent { get; set; }
}
}
I just did some simple tests and was unable to repro this. 我只是做了一些简单的测试,无法对此进行复制。 I see navigation properties for my entities as knockout observables in all of my tests after calling createEntity .
在调用createEntity之后,在所有测试中,我都将实体的导航属性视为可剔除的可观察对象。 A couple of ideas;
一些想法;
Are you sure that you aren't inadvertantly 您确定您不会无意中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.