OData / OData/AspNetCoreOData

Protected setter in Domain model

Open
#167 1 comment 0 reactions 1 assignee View on GitHub

@xuzhg is already working on this.

Since May 21, 2021.

followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

We have several classes with properties having protected setters.
As an example:

public class ProductDictionary : DictionaryModel<int, Product>
{
    public int Id { get; set; }
    public string Series { get; set; }

    //specific code
}

This class is derived from another base class.

public abstract class DictionaryModel<TMasterId, TMaster> where TMaster: IIdentifiable<TMasterId>
{
    public TMasterId MasterId { get; protected set; }
    public virtual TMaster Master { get; protected set; }
    public DateTime? EditedMappingDate { get; protected set; }
    public int? UserId { get; protected set; }

    //specific code to manipulate properties
}

Since there are protected setters for properties, we have this $metadata answer

<EntityType Name="ProductDictionary">
    <Key>
        <PropertyRef Name="Id" />
    </Key>
    <Property Name="Id" Type="Edm.Int32" Nullable="false" />
    <Property Name="Series" Type="Edm.String" />
</EntityType>

We do not want the client of these classes to have direct access to the specified properties.
Is there a way to access these properties without specifying each property in Startup.cs for each EntityType?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.