Skip to content

IsImmutable weird behaviour #507

Closed
@wisepotato

Description

@wisepotato

Lets say I have the following model

using Tbdc.Apis.Mgmt.Authorization;
using Tbdc.Apis.Mgmt.Models.Authorization;
using JsonApiDotNetCore.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Bdc.Api.Management.Models;
using Bdc.Api.Management.Models.Contracts;
using Bdc.Api.Management.Models.Abstract;

namespace Tbdc.Apis.Mgmt.Models
{
    /// <summary>
    /// The user model
    /// </summary>
    public class User :  Identifiable, ITraversable
    {
        [HasMany("cachedReports", canInclude: false), NotMapped]
        public List<Report> CachedReports { get; set; }
        [Attr("firstName", isImmutable: true)]
        public string FirstName { get; set; }

        [Attr("tussenvoegsel", isImmutable: true)]
        public string Tussenvoegsel { get; set; }

        [Attr("fullName", isImmutable: true)]
        public string FullName
        {
            get => this.FirstName + (this.Tussenvoegsel != null ? " " + this.Tussenvoegsel : "") + " " + this.LastName;
        }
        [Attr("lastName", isImmutable: true)]
        public string LastName { get; set; }
    }
}

If I deserialize something coming in that has fullName I dont want it to be set.

Environment

  • JsonApiDotNetCore Version:
  • Other Relevant Package Versions:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions