Base solution for your next web application
Open Closed

how to get the CreatorUser object on DTO layer #4280


User avatar
0
itzoar2 created

Hi all

On Domain layer, my entity is subclass of FullAuditedEntity

May i know how can i retrieve the CreatorUser object on Service layer?

Please advise. Thanks alot

[Table("BankAccount")]
public class BankAccount : FullAuditedEntity
{
    public string AccountNo { get; set; }
    public string AccountName { get; set; }
    public string BankName { get; set; }

}


7 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    You need to inherit FullAuditedEntity<TPrimaryKey, User>:

    public class BankAccount : FullAuditedEntity<int, User>
    
  • User Avatar
    0
    itzoar2 created

    How about the Service layer and the DTO ?

    can i have some example ?

  • User Avatar
    0
    aaron created
    Support Team

    Well, how do you want to use it?

    var account = new BankAccount();
    
    // Insert and SaveChanges
    
    var user = account.CreatorUser;
    
  • User Avatar
    0
    itzoar2 created

    thanks i think my problem has been solved

  • User Avatar
    0
    alper created
    Support Team

    thanks for your feedback ;)

  • User Avatar
    0
    kythor created

    how do you get the CreatorUser in a DTO?

    like i have a list of articles that I want to display, with the name of the creator next to each article.

    I have an ArticleDto that is used from the applicationservice:

    Article = ObjectMapper.Map<ArticleDto>(o)
    

    it used to be easy (maybe it still is) by adding a common CreatorUserDto to the ArticleDto and the CreatorUserDto looked like this:

    [AutoMapFrom(typeof(User))]
        public class CreatorUserDto
        {
            public virtual string UserName { get; set; }
        }
    }
    

    but i guess there is a new way of doing this?

  • User Avatar
    0
    aaron created
    Support Team

    Why would there be a new way? That's already simple and minimal.