2014-08-29 99 views
0

我以微風Edmunds爲例。微風複雜類型數據屬性顯示無數據

正如您在下面看到的,我在Make實體上添加了一個新的名稱數據屬性作爲複雜類型。複雜類型顯示在初始化函數的底部。

在調用web api並返回結果後,我在make結果上看到新的數據屬性,但沒有這個新名稱的數據。如下所示:

Array[61] 
0: proto._setCtor.proto 
_backingStore: Object 
entityAspect: ctor 
id: (...) 
modelLinks: (...) 
models: (...) 
name: "AM General" 
**names**: proto._setCtor.proto 
_backingStore: Object 
complexAspect: ctor 
name: "" 
__proto__: Object 
niceName: (...) 
__proto__: Object 
1: proto._setCtor.proto 
2: proto._setCtor.proto 
3: proto._setCtor.proto 
4: proto._setCtor.proto 
5: proto._setCtor.proto 
6: proto._setCtor.proto 
7: proto._setCtor.proto 
8: proto._setCtor.proto 
9: proto._setCtor.proto 
10: proto._setCtor.proto 
11: proto._setCtor.proto 
12: proto._setCtor.proto 
13: proto._setCtor.proto 
14: proto._setCtor.proto 
15: proto._setCtor.proto 
16: proto._setCtor.proto 
17: proto._setCtor.proto 
18: proto._setCtor.proto 
19: proto._setCtor.proto 
20: proto._setCtor.proto 
21: proto._setCtor.proto 
22: proto._setCtor.proto 
23: proto._setCtor.proto 
24: proto._setCtor.proto 
25: proto._setCtor.proto 
26: proto._setCtor.proto 
27: proto._setCtor.proto 
28: proto._setCtor.proto 
29: proto._setCtor.proto 
30: proto._setCtor.proto 
31: proto._setCtor.proto 
32: proto._setCtor.proto 
33: proto._setCtor.proto 
34: proto._setCtor.proto 
35: proto._setCtor.proto 
36: proto._setCtor.proto 
37: proto._setCtor.proto 
38: proto._setCtor.proto 
39: proto._setCtor.proto 
40: proto._setCtor.proto 
41: proto._setCtor.proto 
42: proto._setCtor.proto 
43: proto._setCtor.proto 
44: proto._setCtor.proto 
45: proto._setCtor.proto 
46: proto._setCtor.proto 
47: proto._setCtor.proto 
48: proto._setCtor.proto 
49: proto._setCtor.proto 
50: proto._setCtor.proto 
51: proto._setCtor.proto 
52: proto._setCtor.proto 
53: proto._setCtor.proto 
54: proto._setCtor.proto 
55: proto._setCtor.proto 
56: proto._setCtor.proto 
57: proto._setCtor.proto 
58: proto._setCtor.proto 
59: proto._setCtor.proto 
60: proto._setCtor.proto 
length: 61 
__proto__: Array[0] 

我缺少什麼?

謝謝...

metadataStore.addEntityType({ 
     shortName: "Make", 
     namespace: "Edmunds", 
     dataProperties: { 
      id:   { dataType: DT.Int64, isPartOfKey: true }, 
      name: { dataType: DT.String }, 
      names: { dataType: DT.ComplexType, complexTypeName: "Names:#Edmunds", isScalar: true }, 
      niceName: { dataType: DT.String }, 
      modelLinks: { dataType: DT.Undefined } 
     }, 
     navigationProperties: { 
      models: { 
       entityTypeName: "Model:#Edmunds", isScalar: false, 
       associationName: "Make_Models" 
      } 
     } 
    }); 

    metadataStore.addEntityType({ 
     shortName: "Names", 
     namespace: "Edmunds", 
     isComplexType: true, 
     dataProperties: { 
      name: { dataType: DT.String, isNullable: false } 
     } 
    }); 

回答

0

如果此示例中修改元數據,您將需要更改「jsonResultsAdapter」代碼。

+0

我做了以下更改,影響 – user3853158 2014-09-02 13:03:45

+0

不知道我理解您的評論。 – 2014-09-02 20:01:44

0
I added the complex type as well as the undefined type and as you can there is no data resturned in the complexy type but the undefined type returned fine. 

Model Changes 

    function initialize(metadataStore) { 
      metadataStore.addEntityType({ 
       shortName: "Make", 
       namespace: "Edmunds", 
       dataProperties: { 
        id: { dataType: DT.Int64, isPartOfKey: true }, 
        modelList: { dataType: DT.ComplexType, complexTypeName: "ModelList:#Edmunds", isScalar: true }, 
        name: { dataType: DT.String }, 
        niceName: { dataType: DT.String }, 
        modelLinks: { dataType: DT.Undefined } 
       } 
       //navigationProperties: { 
       // models: { 
       //  entityTypeName: "Model:#Edmunds", isScalar: false, 
       //  associationName: "Make_Models" 
       // } 
       //} 
      }); 


This is my jsonResultsAdapter code 

visitNode: function (node, parseContext, nodeContext) { 
      // Make parser 
      if (node.id && node.models) { 
       // move 'node.models' links so 'models' can be empty array 
       modelList = node.models; 
       node.modelLinks = node.models; 
       //node.models = []; 
       return { entityType: "Make" } 
      } 

      // Model parser 
      else if (node.id && node.makeId) { 
       // move 'node.make' link so 'make' can be null reference 
       node.makeLink = node.make; 
       node.make = null; 

       // flatten styles and sizes as comma-separated strings 
       var styles = node.categories && node.categories["Vehicle Style"]; 
       node.vehicleStyles = styles && styles.join(", "); 
       var sizes = node.categories && node.categories["Vehicle Size"]; 
       node.vehicleSizes = sizes && sizes.join(", "); 

       return { entityType: "Model" }; 
      } 


This is the results 

未定義型示出了具有陣列數據[1],而複雜的類型顯示數據具有空值,並且proto._setCtor.proto

{ 「makeHolder」:[{ 「ID」: 200347864,「models」:[{「link」:「/ api/vehicle/am-general/hummer」,「id」:「AM_General_Hummer」,「name」:「Hummer」}],「name」 「,」niceName「:」amgeneral「,」manufacturer「:null,」attributeGroups「:{}}]}