Pawel 的帖子是正确的,您应该先致电
微风.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);
}