Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all xp classes into partials #432

Open
ajsuth opened this issue Jun 2, 2022 · 0 comments
Open

Convert all xp classes into partials #432

ajsuth opened this issue Jun 2, 2022 · 0 comments

Comments

@ajsuth
Copy link
Contributor

ajsuth commented Jun 2, 2022

To minimise null value bloat stored in xp of OrderCloud resources, we can update the strongly-typed xp classes to inherit from the OrderCloudModel and IPartial, which will remove unassigned properties during serialisation.

  • Inherit OrderCloudModel and IPartial
  • All properties getters and setters will also need to be reworked to utilise the Props dictionary.
  • The readme will need to be updated to reflect this as a standard practice.
  • Converting xp classes into partial xp classes will not allow default values to be set as this can unintentially override existing xp values during PATCH requests.
  • There is a dependency on updating the OrderCloud .NET SDK to support partial class deserialisation, before we can update xp classes to partials.

See the following example

// Before refactor
public class MyProductXp
{
    public string Note { get; set; }
    public string ProductType { get; set; }
    public bool IsNew { get; set; }
    public decimal Rating { get; set; }
}

// After refactor
public class MyProductXp : OrderCloudModel, IPartial
{
    public string Note { get => GetProp<string>("Note"); set => SetProp<string>("Note", value); }
    public string ProductType { get => GetProp<string>("ProductType"); set => SetProp<string>("ProductType", value); }
    public bool IsNew { get => GetProp<bool>("IsNew"); set => SetProp<bool>("IsNew", value); }
    public decimal Rating { get => GetProp<decimal>("Rating"); set => SetProp<decimal>("Rating", value); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant