Open Closed

set ID #4819


User avatar
0
shobhit created
  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I have following domain class. i have to create a instance and set the Id property. How i can set Id property. (I understand Id is Private so what will be alternate).

public class MyCloass : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
      [NotNull]
        public virtual string Detail { get; set; }

        [NotNull]
        public virtual string Title { get; set; }

}

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can consider:

    public class MyCloass : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
          [NotNull]
          public virtual string Detail { get; set; }
    
          [NotNull]
          public virtual string Title { get; set; }
          
          public void SetId(Guid id)
          {
             Id = id;
          }
    
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19