Javascript “JayData”;未捕获范围错误:超过最大调用堆栈大小;
有一个模型,我希望通过执行以下操作能够记录连接的设备类型:Javascript “JayData”;未捕获范围错误:超过最大调用堆栈大小;,javascript,wcf-data-services,svc,jaydata,Javascript,Wcf Data Services,Svc,Jaydata,有一个模型,我希望通过执行以下操作能够记录连接的设备类型: var connections = DataLayer.context.ConnectionSet.filter(function(item) { return item.Id == id; }, {id: 1}); connections.forEach(function(item) { console.log(item.Sender.Device.DeviceType); }); item.Sender.De
var connections = DataLayer.context.ConnectionSet.filter(function(item) {
return item.Id == id;
}, {id: 1});
connections.forEach(function(item) {
console.log(item.Sender.Device.DeviceType);
});
item.Sender.Device.DeviceType
导致以下错误:
未捕获范围错误:超过最大调用堆栈大小
这是我的模型:
$data.Entity.extend('SubliminalData.Connection', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'Sender': { 'type':'SubliminalData.DevicePort','required':true },
'Receiver': { 'type':'SubliminalData.DevicePort','required':true }
});
$data.Entity.extend('SubliminalData.Device', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'DeviceType': { 'type':'Edm.String','nullable':false,'required':true }
});
$data.Entity.extend('SubliminalData.Port', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true }
});
$data.Entity.extend('SubliminalData.DevicePort', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'Device': { 'type':'SubliminalData.Device','required':true },
'Port': { 'type':'SubliminalData.Port','required':true }
});
为什么这会给我一个最大调用异常,我如何修复它?我找不到它
--更新--
我最近一直在努力让它工作,我已经改变了我的模型,这样我就有了向后导航的属性。现在更合理了,但现在我有另一个问题
新型号:
$data.Entity.extend('SubliminalData.Connection', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'Sender': { 'type':'SubliminalData.DevicePort','required':true,'inverseProperty':'SendingConnections' },
'Receiver': { 'type':'SubliminalData.DevicePort','required':true,'inverseProperty':'ReceivingConnections' }
});
$data.Entity.extend('SubliminalData.Device', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'DeviceType': { 'type':'Edm.String','nullable':false,'required':true },
'DevicePorts': { 'type':'Array','elementType':'SubliminalData.DevicePort','inverseProperty':'Device' }
});
$data.Entity.extend('SubliminalData.Port', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'PortType': { 'type':'Edm.String','nullable':false,'required':true },
'DevicePorts': { 'type':'Array','elementType':'SubliminalData.DevicePort','inverseProperty':'Port' }
});
$data.Entity.extend('SubliminalData.DevicePort', {
'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
'Device': { 'type':'SubliminalData.Device','required':true,'inverseProperty':'DevicePorts' },
'Port': { 'type':'SubliminalData.Port','required':true,'inverseProperty':'DevicePorts' },
'SendingConnections': { 'type':'Array','elementType':'SubliminalData.Connection','inverseProperty':'Sender' },
'ReceivingConnections': { 'type':'Array','elementType':'SubliminalData.Connection','inverseProperty':'Receiver' }
});
$data.EntityContext.extend('DataLayer.SubliminalDataContainer', {
'ConnectionSet': { type: $data.EntitySet, elementType: SubliminalData.Connection },
'DeviceSet': { type: $data.EntitySet, elementType: SubliminalData.Device },
'PortSet': { type: $data.EntitySet, elementType: SubliminalData.Port },
'DevicePortSet': { type: $data.EntitySet, elementType: SubliminalData.DevicePort }
});
$data.generatedContexts = $data.generatedContexts || [];
$data.generatedContexts.push(DataLayer.SubliminalDataContainer);
/*Context Instance*/
DataLayer.context = new DataLayer.SubliminalDataContainer( { name:'oData', oDataServiceHost: 'http://localhost:57703/WcfDataService1.svc' });
我的新问题是:
var connections = DataLayer.context.ConnectionSet.filter(function(item) {
return item.Id == id;
}, {id: 1});
connections.forEach(function(item) {
l(item); //works great!
l(item.Sender); //undefined :[
});
为什么我的发件人没有定义?我以为我懂JayData,但我相信我不懂。你的代码看起来不错,我们认为你从代码的其他部分得到了这个错误, 最有可能来自递归函数调用。
你能用你的代码创建一个JSFIDLE以便我们测试它吗?很抱歉,我们无法提供这么少的信息,请提供更多信息。我的问题已经改变了,也许你可以帮我们解决这个问题?我已更新描述您必须包含它筛选器(..)。包含('发件人')