Skip to content

Async DataPortal call in private field property #1627

Discussion options

You must be logged in to vote

I believe this is what you need.

    public static readonly PropertyInfo<string> BigDataProperty = 
      RegisterProperty<string>(nameof(BigData), RelationshipTypes.PrivateField);
    [NotUndoable, NonSerialized]
    private string _name = BigDataProperty.DefaultValue;
    public string BigData
    {
      get
#pragma warning disable CSLA0007 // Evaluate Properties for Simplicity
      {
        if (string.IsNullOrWhiteSpace(_name))
        {
          Task.Run(async () => 
          {
            var result = await DataPortal.FetchAsync<BigDataLoader>(Id);
            _name = result.BigData;
            OnPropertyChanged(nameof(BigData));
          });
          return BigDataProperty.D…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JacoJordaan
Comment options

Answer selected by JacoJordaan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants