1

In teh .NET SDK your create record method passes a 0 for id on all records as this is unknown until teh response comes back with the id's populated etc

It Seems that the JSON DefaultValueHandling = DefaultValueHandling.Ignore is not working on the freshly minted int '0' id's

An therefore the body has the id:0 and trys inserts the records with id:0 on all and trips a Unique constraint on the inner exception in fiddler

4

1 回答 1

1

我对 DreamFactory 也有类似的问题

我将条件属性序列化属性添加到 Poco/DTO 以用于人员记录作为示例

内部类 StaffRecord {

        public bool ShouldSerializeUid()
        {
            return Uid != 0;
        }

        public int Uid { get; set; }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
        public bool Active { get; set; }

        public override string ToString()
        {
            return string.Format("{0}: name = {1} {2}, age = {3}, active = {4}", Uid, FirstName, LastName, Age, Active);
        }
    }

这现在在序列化/反序列化上都可以正常工作

这是 JSON.NET 文档 条件属性序列化中的文档

干杯:D

于 2016-06-08T13:58:23.383 回答