【问题标题】:Breeze.js: missing property in returned server metadataBreeze.js:返回的服务器元数据中缺少属性
【发布时间】:2015-11-15 21:32:56
【问题描述】:

看起来微风未能在服务器返回的元数据中包含某些属性。我在客户端上使用轻风.js,在服务器上使用轻风-EF,无需进一步配置。这是我的对象

[Table("COEP")]
public class COEP : DataObject
{
    public string ID { get; set; }

    [Required]
    public string COEMID { get; set; }

    [Required]
    public string COJPID { get; set; }

    [Required]
    public string CORGID { get; set; }

    [Required]
    public string CODPID { get; set; }

    [Required]
    public short? COEPISMAIN { get; set; }

    DateTime? STARTDATE { get; set; }

    DateTime? ENDDATE { get; set; }

    [JsonIgnore]
    public virtual COEM COEM { get; set; }
}

这里是部分通过调用从服务器返回的元数据:xxxController.GetMetadata()(我刚刚提到了关于对象COEP的部分)

{"name":"COEP","customannotation:ClrType":"StampDev.Pro.v3.server.EndPoints.Comp.Data.COEP, StampDev.Pro.v3, Version= 1.0.0.0,文化=中性,PublicKeyToken=null", "key":{"propertyRef":{"name":"ID"}}, “财产”:[ {"name":"ID","type":"Edm.String","maxLength":"128","fixedLength":"false","unicode":"true", "可为空":"假"}, {"name":"COEMID","type":"Edm.String","maxLength":"128","fixedLength":"false","unicode":"true", "可为空":"假"}, {"name":"COJPID","type":"Edm.String","maxLength":"Max","fixedLength":"false","unicode":"true", "可为空":"假"}, {"name":"CORGID","type":"Edm.String","maxLength":"Max","fixedLength":"false","unicode":"true", "可为空":"假"}, {"name":"CODPID","type":"Edm.String","maxLength":"Max","fixedLength":"false","unicode":"true", "可为空":"假"}, {"name":"COEPISMAIN","type":"Edm.Int16","nullable":"false"}] "navigationProperty":{"name":"COEM","re​​lationship":"Self.COEM_COEP","fromRole":"COEM_COEP_Target","toRole":"COEM_COEP_Source"}}

您可以清楚地看到没有包含属性“STARTDATE”和“ENDDATE”(可为空的日期时间)。

这些属性没有用 [NotMapped] 属性标记。它们应该包含在元数据中。我不知道这里可能出什么问题。这些属性是我的 MS SQL 数据库的表中存在的字段。

奇怪的是,我还有其他具有 STARTDATE 日期时间属性的对象,它们在元数据中正确返回。更重要的是:对象“COEP”是 主子关系,其中 COEP 是二级子级。任何帮助,任何可能出错的提示都将非常感激。谢谢

【问题讨论】:

    标签: javascript entity-framework breeze


    【解决方案1】:

    您省略了STARTDATEENDDATEpublic 访问修饰符。因此,这些属性默认为私有不映射到表,也不暴露在元数据中。容易错过的事情(因为我发现在过去的半个小时里摸不着头脑)。

    为什么COEPISMAIN 既是[Required] 又是可选的(short?)?

    【讨论】:

    • 非常感谢@ward。我很着急,在最后期限之后,我没有看到它。还需要和短?是一个错误(复制粘贴...)
    猜你喜欢
    • 2021-08-19
    • 1970-01-01
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多