Base solution for your next web application
Open Closed

Return username when using FullAuditedEntity #702


User avatar
0
joemo created

What is the recommended way to return the full username all the to the client (angular) when using FullAuditedEntity ? e.g. get the full user name from the CreatorUserId


3 Answer(s)
  • User Avatar
    0
    sayram created

    If im not missunderstood, you may want to use

    [NotMapped]
            public string Fullname
            {
                get
                {
                    return FirstName + " " + LastName;
                }
            }
    

    in User class. And put the fullname in Output class

  • User Avatar
    0
    joemo created

    Not quite what I meant.... What I mean is... when I've added an Entity with automatic audit fields (e.g. CreatorUserId, CreationTime, etc.) I can see how to access those fields in the app service and pass them through to the client.

    But how do get the corresponding username for that userid? Do I need to access UserManager, and if so - how?

  • User Avatar
    0
    hikalkan created
    Support Team

    You can write a linq to join to Users table. If you're using module-zero, then you can inherit from FullAuditedEntity<TPrimaryKey, TUser>, so User properties also added to your entity and you can use navigation properties to access to related User entity. You can use "Include" (for EF) while gettine entities for performance reason.