我正在寻找使用breezejs,并就其功能和随附的最佳实践提出一些问题.
谢谢
Pawel的帖子是正确的,你应该从打电话开始
breeze.config.initializeAdapterInstances
要实际创建客户端元数据,您可以编写类似这样的内容.(一个简单的例子).
initializeMetadataStore(myEntityManager.metadataStore);
function initializeMetadataStore(metadataStore) {
var et = new EntityType({
shortName: "Person",
namespace: "Sample_WebApi.Models"
});
et.addProperty( new DataProperty({
name: "personId",
dataType: DataType.Int32,
isNullable: false,
isPartOfKey: true,
}));
et.addProperty(new DataProperty({
name: "firstName",
dataType: DataType.String,
isNullable: false,
}));
et.addProperty(new DataProperty({
name: "lastName",
dataType: DataType.String,
isNullable: false,
}));
et.addProperty(new DataProperty({
name: "birthDate",
dataType: DataType.DateTime,
isNullable: true
}));
et.addProperty(new NavigationProperty({
name: "meals",
entityTypeName: "Meal",
isScalar: false,
associationName: "personMeals"
}));
metadataStore.addEntityType(et);
et = new EntityType({
shortName: "Meal",
namespace: "Sample_WebApi.Models"
});
et.addProperty(new DataProperty({
name: "mealId",
dataType: DataType.Int32,
isNullable: false,
isPartOfKey: true,
}));
et.addProperty(new DataProperty({
name: "personId",
dataType: DataType.Int32,
isNullable: false,
}));
et.addProperty(new DataProperty({
name: "dateConsumed",
dataType: DataType.DateTime,
isNullable: false,
}));
et.addProperty(new NavigationProperty({
name: "person",
entityTypeName: "Person",
isScalar: true,
associationName: "personMeals",
foreignKeyNames: ["personId"]
}));
et.addProperty(new NavigationProperty({
name: "dishes",
entityTypeName: "Dish",
isScalar: false,
associationName: "mealDishes",
}));
metadataStore.addEntityType(et);
et = new EntityType({
shortName: "Dish",
namespace: "Sample_WebApi.Models"
});
et.addProperty(new DataProperty({
name: "dishId",
dataType: DataType.Int32,
isNullable: false,
isPartOfKey: true,
}));
et.addProperty(new DataProperty({
name: "foodName",
dataType: DataType.String,
isNullable: false,
}));
et.addProperty(new DataProperty({
name: "servingSize",
dataType: DataType.Double,
isNullable: false,
}));
et.addProperty(new NavigationProperty({
name: "food",
entityTypeName: "Food",
isScalar: true,
associationName: "DishFood",
foreignKeyNames: ["foodName"]
}));
metadataStore.addEntityType(et);
et = new EntityType({
shortName: "Food",
namespace: "Sample_WebApi.Models"
});
et.addProperty(new DataProperty({
name: "foodName",
dataType: DataType.String,
isNullable: false,
isPartOfKey: true,
}));
et.addProperty(new DataProperty({
name: "calories",
dataType: DataType.Int32,
isNullable: false,
}));
metadataStore.addEntityType(et);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2676 次 |
| 最近记录: |