在分析breeze元数据文件的早期版本的breeze中,我会看到一种格式,显示描述DBContext的详细的元数据json格式。
Breeze的例子就是这样的一个例子:
{
"schema":{
"namespace":"Todo.Models",
"alias":"Self",
"annotation:UseStrongSpatialTypes":"false",
"xmlns:annotation":"http://schemas.microsoft.com/ado/2009/02/edm/annotation",
"xmlns":"http://schemas.microsoft.com/ado/2009/11/edm",
"cSpaceOSpaceMapping":"[[\"Todo.Models.TodoItem\",\"Todo.Models.TodoItem\"]]",
"entityType":{
"name":"TodoItem",
"key":{
"propertyRef":{
"name":"Id"
}
},
"property":[
{
"name":"Id",
"type":"Edm.Int32",
"nullable":"false",
"annotation:StoreGeneratedPattern":"Identity"
},
{
"name":"Description",
"type":"Edm.String",
"maxLength":"30",
"fixedLength":"false",
"unicode":"true",
"nullable":"false"
},
{
"name":"CreatedAt",
"type":"Edm.DateTime",
"nullable":"false"
},
{
"name":"IsDone",
"type":"Edm.Boolean",
"nullable":"false"
},
{
"name":"IsArchived",
"type":"Edm.Boolean",
"nullable":"false"
}
]
},
"entityContainer":{
"name":"TodosContext",
"entitySet":{
"name":"Todos",
"entityType":"Self.TodoItem"
}
}
}
}
但是现在在运行这个新版本的微风之后,点击我的元数据文件,我发现这个奇怪的怪异:
{
"?xml":{
"version":"1.0",
"encoding":"utf-8"
},
"schema":{
"namespace":"DBModel",
"alias":"Self",
"annotation:UseStrongSpatialTypes":"false",
"xmlns:annotation":"http://schemas.microsoft.com/ado/2009/02/edm/annotation",
"xmlns:customannotation":"http://schemas.microsoft.com/ado/2013/11/edm/customannotation",
"xmlns":"http://schemas.microsoft.com/ado/2009/11/edm",
"cSpaceOSpaceMapping":"[[\"DBModel.User\",\"Model.User\"]]",
"entityContainer":{
"name":"DBEntities",
"annotation:LazyLoadingEnabled":"true",
"entitySet":{
"name":"Users",
"entityType":"DBModel.User"
}
},
"entityType":{
"name":"User",
"key":{
"propertyRef":{
"name":"Id"
}
},
"property":[
{
"name":"Id",
"type":"Edm.Int64",
"nullable":"false",
"annotation:StoreGeneratedPattern":"Identity"
},
{
"name":"Firstname",
"type":"Edm.String",
"maxLength":"40",
"fixedLength":"false",
"unicode":"false"
},
{
"name":"Lastname",
"type":"Edm.String",
"maxLength":"60",
"fixedLength":"false",
"unicode":"false"
},
{
"name":"Email",
"type":"Edm.String",
"nullable":"false",
"maxLength":"128",
"fixedLength":"false",
"unicode":"false"
}
]
}
}
}
在元数据中包含xml信息有什么意义?微风如何能够从这两个版本之间的元数据中获取信息并仍然可以正常工作?
答案 0 :(得分:1)
EFContextProvider(在breeze.server.net中)基本上只是将EntityFramework中的元数据信息从XML转换为JSON,然后将其发送回Breeze客户端。 Breeze客户端知道如何从JSON格式获得它所需要的东西,即使有一些额外的XML相关位被添加。
基本上,Breeze忽略了不相关的部分。在较新版本的EF中,XML中的额外内容已经扩展,但基本结构保持不变。