2013-11-25 77 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在反向導航

相關問題