Skip to content

Get rid of the need to add attribute to reference properties #9

@Shaddix

Description

@Shaddix

Now to sync references you have to do the following:

  1. Server-side:
    have a scalar property with reference's key to pass to the client. E.g.:
        [ForeignKey(nameof(ReplyId))]
        [JsonIgnore]
        public virtual Message Reply { get; set; }
        public string ReplyId { get; set; }

That way ReplyId property is synced between the server and the client.

  1. Client-side:
        [JsonProperty("ReplyId")]
        [JsonConverter(typeof(RealmReferencesSerializer))]
        public Message Reply { get; set; }
  1. For many-to-many we don't need [JsonProperty] on the client, but we need JsonConverter on the server:
        [JsonConverter(typeof(RealmServerCollectionConverter))]
        public virtual IList<ItemCategory> Categories { get; set; }

Since we control json serialization on both ends, there should not be a need for the user to put in additional attributes

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions