我在我的第一次尝试拉满实体图形与微风和EF6(Hottowel /约翰·帕帕味)微风扩展性能 - 如何在控制器阵列
我有一个实体失踪的理解的关键部分引用的政策-P_Locations-P_Hazards父子,祖孙关系
我希望看到所有策略的图形为一个客户
总之我查询返回形在我所期望的JSON(在XHR证实查看器)和data.results允许我深入(通过bac kingstore - man我们需要像C#这样的JavaScript浏览器)来查看儿童和孙子的数组。我看到所有的政策,地点和危害我希望为客户端(DLL版本和型号/ modelmap代码在帖子的末尾)
的DataContext:
function getPoliciesByClientsId(clientsid) {
var policies;
return EntityQuery.from('Policies')
.withParameters({ clientsid: clientsid })
.expand('P_Locations, P_Locations.P_Hazards')
.using(manager).execute()
.then(querySucceeded, _queryFailed);
function querySucceeded(data) {
policies = data.results;
log('Retrieved [Policy] from remote data source', policies.length, true);
return policies;
}
}
控制器:
function getPoliciesByClientsId(clientsid) {
return datacontext.getPoliciesByClientsId(clientsid).then(function(data) {
vm.Policies = [];
vm.Policies = data;
// at this point vm.Policies shows an object array
// and I can see p_Locations for each policy and p_Hazards for each location
// but vm.Policies.p_locations is undefined
return vm.Policies;
}
);
}
如果我深入研究datacontext中的策略或控制器中的vm.Policies中的策略,我会看到骆驼封装的数组。
但
vm.Policies.p_Locations是不确定的。当然,我也想引用vm.Policies.p_Locations.p_Hazards。
我为了参考绑定数据图而丢失了什么?
BreezeController:
[HttpGet]
public IQueryable<Policy> Policies()
{
return _repository.Policies;
}
PwiRepository
public IQueryable<Policy> Policies
{
get { return Context.Policies; }
}
而创建此要求:
Request URL:http://localhost:29130/breeze/Breeze/Policies?$expand=P_Locations%2CP_Locations%2FP_Hazards&clients_id=439
使用manager.metadataStore。getEntityType(“P_Location”),然后钻进去导航性能我发现这些
navigationProperties: Array[4]0:
dassociationName: "P_Hazard_P_Location"
entityType: l
entityTypeName: "P_Hazard:#Pwi.Model.Models"
foreignKeyNames: Array[0]
foreignKeyNamesOnServer: Array[0]
invForeignKeyNames: Array[1]
invForeignKeyNamesOnServer: Array[1]
inverse: disScalar: falsename: "p_Hazards"
nameOnServer: "P_Hazards"
parentType: lvalidators: Array[0]
associationName: "P_Location_Policy"
entityType: lentityTypeName: "Policy:#Pwi.Model.Models"
foreignKeyNames: Array[1]
foreignKeyNamesOnServer: Array[1]
invForeignKeyNames: Array[0]
invForeignKeyNamesOnServer: Array[0]
inverse: disScalar: truename: "policy"
nameOnServer: "Policy"parentType: l
relatedDataProperties: Array[1]validators: Array[0]__proto__: Objectlength: 4
这里是DLL 件
<packages>
<package id="Breeze.Server.ContextProvider" version="1.4.17" targetFramework="net45" />
<package id="Breeze.Server.ContextProvider.EF6" version="1.4.17" targetFramework="net45" />
<package id="Breeze.Server.WebApi2" version="1.4.17" targetFramework="net45" />
<package id="EntityFramework" version="6.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.OData" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.0" targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.6.2" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.2" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4.0" targetFramework="net45" />
<package id="System.Spatial" version="5.6.2" targetFramework="net45" />
<package id="WebActivator" version="1.5.3" targetFramework="net45" />
</packages>
我有策略 - 的父子,祖孙关系P_Locations-P_Hazards 以下是模型和模型映射的相关部分
P_Location型号:
public partial class P_Location
{
public P_Location()
{
this.P_GlCoverages = new List<P_GlCoverage>();
this.P_Hazards = new List<P_Hazard>();
this.P_PropertyCoverages = new List<P_PropertyCoverage>();
}
public int P_Locations_id { get; set; }
public int Policies_id { get; set; }
......
public virtual Policy Policy { get; set; }
public virtual ICollection<P_Hazard> P_Hazards { get; set; }
P_LocationMap
// Relationships
this.HasRequired(t => t.Policy)
.WithMany(t => t.P_Locations)
.HasForeignKey(d => d.Policies_id);
P_Hazard型号
public Policy Policy { get; set; }
public P_Location P_Location { get; set; }
P_HazardMap
// Relationships
this.HasRequired(t => t.P_Location)
.WithMany(t => t.P_Hazards)
.HasForeignKey(d => d.P_Locations_id);
进入孙子的每个实体似乎都有一个entityAspect属性。如果我钻到p_Locations entityAspect.entityManager我看到metadataStore:我 _ctorRegistry:对象 _deferredTypes:对象 _entityTypeResourceMap:对象 ... P_Hazard:#Pwi.Model.Models: “P_Hazards” P_Location:#Pwi.Model。模型:“P_Locations” ... 策略:#Pwi.Model.Models:“策略” __proto__:这是我期望的模型对象。在原始问题中发布上面的服务器端代码。 – 2014-09-01 18:38:42
我不确定我是否真的在意,但谁能告诉我谁投票否决了这个问题,为什么?我认为它彻底解释了这个问题,并直接针对杰伊的请求发布了更多信息。 – 2014-09-01 19:32:52
好的,重新阅读你的文章,当你说“看到所有的政策,地点和危害”,但“Policies.p_Locations未定义”时,我不确定我是否理解。你怎么能有两个?你在哪里“看到”政策,地点和危害?此外,您应该访问“then”承诺中的“data.results”属性,而不仅仅是“数据”。 – 2014-09-01 19:57:17