Skip to content

Expand property bag definition #22009

Open

Description

@AndriySvyryd

Look for IDictionary<string, object> implementation or just look for an indexer and ContainsKey() method.

Add Fluent API to configure an ET as a Property bag or not.

Activity

  1. added this to the Backlog milestone on Aug 14, 2020
  2. ajcvickers commented on Aug 26, 2020

    @ajcvickers
    Contributor

    I'm finding it hard to use property bags without this; should we pull it into 5.0?

    For example, I thought this would work:

    public class ProxyableSharedType
    {
        private readonly Dictionary<string, object> _keyValueStore = new Dictionary<string, object>();
    
        public virtual object this[string key]
        {
            get => _keyValueStore.TryGetValue(key, out var value) ? value : default;
            set => _keyValueStore[key] = value;
        }
    }
    modelBuilder.SharedTypeEntity<ProxyableSharedType>(
        "PST", b =>
        {
            b.IndexerProperty<int>("Id").ValueGeneratedNever();
            b.IndexerProperty<string>("Payload");
        });

    But it doesn't because initially "Id" is not in the dictionary, so null is returned by the indexer, but the property doesn't support nulls.

  3. removed this from the Backlog milestone on Aug 26, 2020
  4. smitpatel commented on Aug 26, 2020

    @smitpatel
    Contributor

    Should property getter for indexer property account for the fact that object is returned from indexer (which could be null) and convert it to appropriate CLR default?

  5. ajcvickers commented on Aug 26, 2020

    @ajcvickers
    Contributor

    @smitpatel Possibly; I can look at making it act like a nulable backing field.

  6. added this to the Backlog milestone on Aug 28, 2020
  7. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions