2013-11-25 39 views
2

我对这个贴子发布了一个新问题,所以请温柔!TypeError:对象[对象数组]没有方法'getProperty'

我使用Breeze作为“Hot Towel”SPA堆栈的一部分,并从用PHP编写的自定义WebApi端点检索数据。这不是一个完整的实现,我只写了足够的东西给我我需要的东西。

我的端点生成的元数据如下:

{ 
     "shortName": "Project", 
     "namespace": "WebApi.ORM.Cartesius", 
     "autoGeneratedKeyType": "Identity", 
     "defaultResourceName": "Project", 
     "dataProperties": [ 
      { 
       "name": "id", 
       "isPartOfKey": true, 
       "isNullable": false, 
       "dataType": "Int32" 
      }, 
      { 
       "name": "title", 
       "isNullable": false, 
       "maxLength": 256, 
       "dataType": "String" 
      }, 
      { 
       "name": "date", 
       "isNullable": false, 
       "dataType": "DateTime" 
      }, 
      { 
       "name": "review_date", 
       "isNullable": true, 
       "dataType": "DateTime" 
      }, 
      { 
       "name": "summary", 
       "isNullable": true, 
       "dataType": "String" 
      } 
     ], 
     "navigationProperties": [ 
      { 
       "name": "Team", 
       "entityTypeName": "Team:#WebApi.ORM.Cartesius", 
       "isScalar": true, 
       "associationName": "team_project_id_fkey", 
       "invForeignKeyNames": [ 
        "project_id" 
       ] 
      }, 
      { 
       "name": "ProjectAuthor", 
       "entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius", 
       "isScalar": true, 
       "associationName": "project_author_project_id_fkey", 
       "invForeignKeyNames": [ 
        "project_id" 
       ] 
      }, 
      { 
       "name": "Itinerary", 
       "entityTypeName": "Itinerary:#WebApi.ORM.Cartesius", 
       "isScalar": true, 
       "associationName": "itinerary_project_id_fkey", 
       "invForeignKeyNames": [ 
        "project_id" 
       ] 
      }, 

一切工作正常,直到我尝试做我查询的扩展:

var query = new breeze.EntityQuery() 
     .from("Project") 
     .where("id","eq",project.id) 
     .expand("ProjectAuthor"); 

该查询返回从下面的我终点:

[ 
{ 
    "$id": 1, 
    "$type": "WebApi.ORM.Cartesius.Project", 
    "id": 2, 
    "title": "teat", 
    "date": "2013-11-04 14:00:00+07", 
    "review_date": null, 
    "summary": null, 
    "ProjectAuthor": [ 
     { 
      "$id": 2, 
      "$type": "WebApi.ORM.Cartesius.ProjectAuthor", 
      "id": 1, 
      "account_id": 1, 
      "project_id": 2, 
      "Project": [ 
       { 
        "$ref": 1 
       } 
      ] 
     }, 
     { 
      "$id": 3, 
      "$type": "WebApi.ORM.Cartesius.ProjectAuthor", 
      "id": 3, 
      "account_id": 2, 
      "project_id": 2, 
      "Project": [ 
       { 
        "$ref": 1 
       } 
      ] 
     } 
    ] 
} 

]

然后微风扼流圈它扔:

TypeError: Object [object Array] has no method 'getProperty' 

调试点在清风行5059它尝试的getProperty实体的阵列,而不是我以为这有一些东西与是否导航单个实体上财产被设置为标量或不是,但切换它们没有区别。

我确定我在做大量错误的事情,但我无法弄清楚它是什么,而且我碰到了一堵砖墙。我已经从顶部到底部阅读了文档,并且尽我所能地理解了这一点,但可能我有点困惑。

预先感谢任何帮助和道歉,如果我没有说清楚或提供足够的信息

回答

0

我觉得你的问题是在元数据

 "name": "ProjectAuthor", 
      "entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius", 
      "isScalar": true, 
      "associationName": "project_author_project_id_fkey", 
      "invForeignKeyNames": [ 
       "project_id" 
      ] 
     }, 

在那个导航性能项目 - > ProjectAuthor你告诉它,它的一个标量,但它不是在数据集.. “ProjectAuthor”:[{ ..........

我有这个问题藏汉.. 99% TI我它是一个元数据问题,如果不是那里,然后开始削减元数据分开,直到你隔离错误..虽然我相信多数民众赞成在问题..你需要一个hasMany那里和isScalar在反向导航

相关问题