在 BreezeJS 客户端中解析元数据时出现异常

2024-01-23

前传和版本信息:

BreezeJS客户端版本:1.5.2

通过设计时 EntityFramework 模型在自定义服务器上生成的元数据 (6.1.2)

BreezeLabs EdmBuilder (1.0.5)

生成元数据时也遇到问题,可以在此处阅读:如何通过 EdmBuilder for OData v3/BreezeJS 从 EF DBContext 生成有效元数据 https://stackoverflow.com/questions/28077699/how-to-generate-valid-metadata-from-ef-dbcontext-via-edmbuilder-for-odata-v3-bre


问题/问题:

现在,微风客户端在解释元数据时抛出错误。

Unable to process returned metadata: A nonnullable DataProperty cannot have a null defaultValue. Name: MySuperDuperEnum

异常发生在breeze.debug.js at line 7110 - function parseCsdlSimpleProperty(parentType, csdlProperty, keyNamesOnServer).

这里出了什么问题?我的元数据有错误吗?

这是元数据:

<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
    <edmx:DataServices m:DataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
        <Schema Namespace="ODataMetaDataGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">

            <EntityType Name="MyObject" p5:ClrType="GreatPersistencyNamespace.Model.GreatStuff.MyObject, BreezeEval, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:p5="http://schemas.microsoft.com/ado/2013/11/edm/customannotation">
                <Key>
                    <PropertyRef Name="ID"/>
                </Key>
                <Property Name="ID" Nullable="false" Type="Edm.Int32" p7:StoreGeneratedPattern="Identity" xmlns:p7="http://schemas.microsoft.com/ado/2009/02/edm/annotation"/>
                <Property FixedLength="false" MaxLength="Max" Name="Name" Type="Edm.String" Unicode="true"/>
                <Property Name="IsActive" Nullable="false" Type="Edm.Boolean"/>
                <Property Name="IsGreat" Nullable="false" Type="Edm.Boolean"/>
                <Property FixedLength="false" MaxLength="Max" Name="Description" Type="Edm.String" Unicode="true"/>
                <Property Name="Address" Nullable="false" Type="ODataMetaDataGenerator.Address"/>
                <Property Name="BehaviourType" Nullable="false" Type="ODataMetaDataGenerator.BehaviourType"/>
            </EntityType>

            <EnumType Name="BehaviourType" UnderlyingType="Edm.Byte" p5:ClrType="GreatPersistencyNamespace.Model.GreatStuff.BehaviourType, BreezeEval, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:p5="http://schemas.microsoft.com/ado/2013/11/edm/customannotation">
                    <Member Name="RUDE" Value="1"/>
                    <Member Name="KIND" Value="2"/>
                    <Member Name="UNKNOWN" Value="3"/>
            </EnumType>

            <EntityContainer Name="TheGreatModelContainer" p5:UseClrTypes="true" xmlns:p5="http://schemas.microsoft.com/ado/2013/11/edm/customannotation"   >
                    <EntitySet EntityType="ODataMetaDataGenerator.MyObject" Name="MyObjects"/>
            </EntityContainer>

        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

错误的确切来源是breeze.debug.js at line 8597 - constructor of DataProperty.

必须设置 defaultValue,在我的例子中,它尝试从属性 dataType 获取默认值。 此时的 dataType 如下所示:

{
    name: "Undefined",
    defaultValue: undefined
}

发生这种情况是由于失败line 7091 - var dataType = DataType.fromEdmDataType(csdlProperty.type);

因为 csdlProperty 看起来像:

{
    name: "BehaviourType",
    nullable: undefined
    type: "ODataMetaDataGenerator.BehaviourType"
}

这当然不是 Edm 类型,因此失败了。这里应该使用枚举的基础类型吗?


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 BreezeJS 客户端中解析元数据时出现异常 的相关文章

随机推荐